Re: Re: [RFC] Iterable
| From: | Fleshgrinder | Date: | Mon, 13 Jun 2016 17:11:31 +0000 |
| Subject: | Re: Re: [RFC] Iterable | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93943@lists.php.net to get a copy of this message | ||
On 6/13/2016 5:59 PM, Levi Morrison wrote:
> My opinion is contrary: the union type is the cleaner solution as it
> does not require special casing machinery in the engine.
>
I am a huge fan of the union types but this is such a common requirement
that it requires a pseudo compound type in my opinion. The special
casing in the engine is trivial:
https://github.com/php/php-src/pull/1941
I also hope that this allows expansion in internals and enable us to
rewrite existing functions from array to iterable and directly iterate
them without special casing.
Furthermore I argue the we need more of those pseudo compound types that
are special in internals and userland and I might implemented them if I
am ever going to be granted some Karma:
number := is_numeric || is_int || is_float
stringable := is_string || method_exists(__toString)
These three things cannot even be easily expressed with union types.
(Well, the last one can if one creates a Stringable interface and you
end up having string|Stringable :P)
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc