On 21/04/11 08:56, Arpad Ray wrote: > On Thu, Apr 14, 2011 at 3:05 PM, Hannes Landeholm <landeh...@gmail.com> wrote: >> Some suggested that the ternary if comparison should suppress the notice >> automatically. This would break existing code and also be confusing since >> people expect a ternary if and normal if to work the same way. >> >> Some suggested ?? as an array access operator that suppresses the notice and >> has 3 variants: A: nothing specified - uses null as default, B: has default >> specified, C: returns X if index exists or Y if index doesn't exist. This >> effectively solves the code duplication problem and is a shortcut for saying >> "the array index may or may not exist". >> >> One person said that the relation between ? and ?? and == and === would make >> the operator non-intuitive. Other people disagreed and claimed the opposite. >> >> So basically the discussion now is what exact characters that should be used >> to represent this operator? I really hope we can get this implemented >> quickly... I worked with $_POST yesterday and I could really use that ?? >> operator. > Hi, > > I must say that the prospect of yet more new syntax is scary. It > really looks like Perl, and I wouldn't have the slightest clue what it > meant if I'd missed the release notes. > > I've pined for something like coalesce($_GET['foo'], $defaults['foo'], > 42) for years, and I think that style is far more in keeping with the > PHP ethos, and far more readily understandable than this suggested new > syntax. > > If I've missed some argument against this then please correct me. > > Regards, > > Arpad >
What does coalesce() do? If I'm guessing correctly, would proposal #2 that Rune Kaagaard put up solve that for you? https://gist.github.com/909711 Cheers, David -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php