Re: [RFC] Default constructors
| From: | Rowan Collins | Date: | Tue, 18 Nov 2014 23:16:10 +0000 |
| Subject: | Re: [RFC] Default constructors | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78970@lists.php.net to get a copy of this message | ||
On 18/11/2014 23:07, Stanislav Malyshev wrote:
Hi!I don't know the innards of the engine well enough to follow this, but it sounds like you're talking about skipping the evaluation of __construct() as a method if it doesn't exist as one, which is perfectly reasonable. However, the side effect that the *arguments* to that function call are not executed is surely an unintended side-effect of this, which was considered not important enough to worry about.Are you sure it was intended to work this way, with the parameters not being evaluated at all?Of course, just look at how ZEND_NEW opcode is written. It's the only reason in has op2 there. That code is not a typo, it's intended to skip the function call.
I personally am not completely sure it's worth the trouble - since, again, no sane code should ever rely on something like this - but maybe I'm wrong that there's a valid use case for this.Sorry, I'm not sure what you are referring to by "this" here. To quote an earlier example: $b = 0; $a = new Foo(++$b); Looks like pretty normal code to me; no reason to expect anything about the way class Foo is defined to affect its behaviour. No sane code should rely on that *not* incrementing $b, surely? -- Rowan Collins [IMSoP]