On 04/07/2011 07:02 PM, Stas Malyshev wrote:
Hi!

$value = isset($a[$key]) ? $a[$key] : 'Not set';

which is exactly the situation I had before it was introduced.

Not sure why you would have that expectation. The long ternary doesn't
do that, and there is nothing about the short ternary that changes that.

It is true, however I think the amount of boilerplate code produces by
this paradigm is staggering, and it's about time we fixed that. We had a
chance of doing it with ?: but for one reason or another it was passed,
but the need is still there. I think actually the idea of "expr ??
expr2", meaning (isset($expr)?$expr:$expr2) is not bad. Anybody sees any
holes in it?
And yes, I wouldn't be disappointed too much if ?: didn't generate
notices either. With modern IDEs times when it helped catch typos are
mostly gone, and now these warnings are just a very annoying reason to
write boilerplate code.

I'm not against coming up with a cleaner no-warning mechanism for this. I was just responding to the idea that the intent of ?: was to solve this. It never was. We need to be careful about changing the beahviour of existing operators.

-Rasmus

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

Reply via email to