Hi! > Take a look at the "short circuit" section where I specifically > address this. It was done to make it easier to reason about in a > side-effect-ful language like PHP. With this behavior, when you see > > $x?->f(g(), h())
I think this is weird magic behavior which should not be part of PHP. If $x is null, there's no object to call f on, and as such f() call is not executed. However, if argument still be evaluated even though the call is never done, this makes no sense at all - why evaluate the arguments if there's nothing to call? Moreover, what if g() and h() actually use $x assuming - quite right, since we're calling the method on it - that $x is not null? Moreover, having code depending on side effect of function call which is not part of the call itself is extremely bad style (i.e., what happens if g() throws exception and h() is never called?) and should not be encouraged. > -- we in fact don't make the method call, but we still prepare > everything as if we were going to, and just decide not to do it at > the last moment. Which, again, makes little sense - if we know there would be no call, why prepare everything and decide at the last moment? It's like you know your flight was cancelled, but you still drive to the airport, pass security, give the baggage to the airline, show up at the gate, wait until the last moment and then - surpries! it's still cancelled! - so you take your baggage back and drive back home. Why would anybody do that? > I feel pretty strongly that this is the correct behavior. It may > sound strange when talking about isolated examples like this, but in It does sound strange. > the real-world code I've seen, it is the least confusing. (I'll see Which real-world code you are talking about? Examples please. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php