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: signature.asc
Description: OpenPGP digital signature

Reply via email to