Re: Execution order of PHP
| From: | Auke van Slooten | Date: | Wed, 10 Mar 2010 14:23:43 +0000 |
| Subject: | Re: Execution order of PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302660@lists.php.net to get a copy of this message | ||
Bob McConnell wrote:
From: Auke van SlootenI don't mind about the order in which the parameters are evaluated. The only thing that must stay the same for my code to work as designed is that $client->system is evaluated before any of the arguments to the multiCall method. Your explanation seems reasonable to me, but I've been informed by people that know more about parsers and compilers than me, that theoretically there is no requirement for this to be true... After a further education just now, it is possible for a compiler to parse the entire multiCall right to left, so it will first evaluate $client->methodTwo(), then $client->methodOne() and only then resolves $client->system->multiCall. Before evaluating this call, the compiler can still check whether the number of arguments matches the parameter list of the function definition. Anyway, the point is that I'd like to be able to write multiCall statements like written above instead of doing something like this: $client->system->multiCall( array( 'method' => 'methodOne',In a hobby project I'm relying on the order in which the followingpieceof PHP code is executed: $client->system->multiCall( $client->methodOne(), $client->methodTwo() );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.
'params' => array() ),array( 'method' => 'methodTwo',
'params' => array() )); regards, Auke van Slooten Muze