On Dec 10, 2014, at 12:30 PM, Robert Stoll <p...@tutteli.ch> wrote: > I stick with it, evaluating it does not make sense IMO. If I want to execute > it in any case then I would do something > like this currently > > $g = g(); > $h = h(); > if($x !== null){ > $x->foo($g, $h)->bar(baz()); > } > > And with the ?-> operator: > > $g = g(); > $h = h(); > $x?->foo($g, $h)?->bar(baz()); > > Where I do not expect that baz() is called.
You can make exactly the opposite argument too, though. I *do* expect that baz() would be called, and I can always explicitly write it the other way if that happens to not be what I want at some point. > You wrote it will be confusing for the user if the arguments would not be > evaluated. I do not think so, telling them it is a short form for ($x !== > null ? $x->foo() : null) is very easy and > straight forward for the user to pick up. I think it's confusing the other way, and "instead of raising a fatal for calling a method on null, it returns null" is just as simple of an explanation. > Therefore, please dig up a better example. Yeah, gonna go do this now, had a busy morning :) All of that said: it's not clear to me that this actually matters that much. I wasn't able to quickly find an example because the vast majority of the Hack code I have that uses this operator isn't actually affected one way or the other. Josh -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php