On Wed, 2010-03-10 at 15:20 +0100, Sándor Tamás wrote: > > 2010.03.10. 14:41 keltezéssel, Bob McConnell írta: > > From: Auke van Slooten > > > > > >> In a hobby project I'm relying on the order in which the following > >> > > piece > > > >> of PHP code is executed: > >> > >> $client->system->multiCall( > >> $client->methodOne(), > >> $client->methodTwo() > >> ); > >> > >> Currently PHP always resolves $client->system (and executes the __get > >> > > on > > > >> $client) before resolving the arguments to the multiCall() method > >> > > call. > > > >> Is this order something that is specified by PHP and so can be relied > >> upon to stay the same in the future or is it just how it currently > >> > > works. > > > >> If it cannot be relied upon to stay this way, I will have to rewrite > >> > > the > > > >> multiCall method and API... > >> > > Think about it from the parser's point of view. It has to evaluate > > $client->system to determine the parameter list for multiCall(). Then it > > has to evaluate those parameters before it can stuff their values into > > the stack so it can call the function. But, whether it evaluates the > > parameter list left-to-right or vice versa is implementation dependent. > > I don't believe you can rely on it always being the same unless you > > always use the same interpreter. > > > > Bob McConnell > > > > > I think it cannot be that the evaluation order of the parameters is > implementation dependent. > Just think about it: > $someobject->method($a++, $a++); > > What will be the result? Or there has to be some directive to tell the > parser to evaluate the parameters from left to right or vice versa. > And if there isn't, in some future release, there has to be. > > SanTa > The order is implementation dependent, and just follows from other languages which behave exactly the same (I believe Java and C++ both do) This is the sort of example that's used as a reason to not rely on such behaviour. You just have to work around it I guess. Thanks, Ash http://www.ashleysheridan.co.uk