On 4/14/16 3:25 PM, Fleshgrinder wrote:
On 4/14/2016 8:59 PM, Stanislav Malyshev wrote:
>Hi!
>
>>I don't know what is complicated about "string|Stringable" or "Foo|Bar"
>>since it is super self-explanatory. However, I find myself checking the
>
>It may be self-explanatory for you. It's much less self-explanatory for
>somebody just starting to learn. It is also very dangerous - if it's
>either Foo or Bar, can you call Foo::stuff on it or not? If it's string
>or not string, can you call strlen on it? Etc., etc. It adds a lot of
>cognitive load and complicates the whole picture. You may have a
>specific use case where it is useful (which we have yet to see btw) but
>please remember it's a language with literally millions of use cases and
>users.
>
Reduce assertions*, enhance self-documentation, making code more robust,

I disagree here. I think our programs are more robust when programmers avoid passing mixed types and write more simple code instead.

Hence I agree with Stas about the danger part. Union type hints are a hazard. Adding them to PHP as a new feature is like saying "here's a great new tool, pick it up and use it" but the tool is really a footgun.

Tom


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to