On 2011-04-11, Stas Malyshev <smalys...@sugarcrm.com> wrote: > > I might come off rather crumudgeonly here, but these last few > > threads I've seen going across to silence notices have a common > > theme - "I wanna be a lazier coder." > > Laziness is a virtue for a coder :) At least, when it goes to avoid > unnecessary work - in this example, boilerplate code. > > > Which is fine - set the PHP error level to not show them. > > This is not good enough - "not showed" errors are still generated and > are quite expensive. > > > But don't ask the engine to be rewritten to encourage bad coding > > practices which failing to properly initialize variables is a prime > > example of. It's > > The case we're dealing with is specifically about providing resolution > for the case when the value is not initialized and the default value > is provided. It is about making good code easier to write ("$foo[$bar] > ?? $baz" instead of "isset($foo[$bar])?$foo[$bar]:$bar").
+1 This is precisely the use case I originally (erroneously) thought the ternary shortcut was for. It's not uncommon to use nested arrays or objects for configuration -- and configuration is one place where you may or may not have values. Having a shortcut to retrieve the value if present or provide a default is not just laziness, but also a way to improve your coding -- by removing yet another place for a typo. (Type the array/object access ONCE instead of TWICE.) -- Matthew Weier O'Phinney Project Lead | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php