Hi!

> 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.

> Is that actually useful in any context? Function calls always evaluate
their arguments, do they not? PHP is a language with functions that have
side effects.

That's why, again, ZEND_NEW opcode has op2 - if ctor is not defined, it
does not initiate the function call. It'd be hard to initiate it since
there's no actual function there, but of course with some work and
additional branches in the code that executes functions it probably can
be done.

> Alright then, it’s a “feature” that needs fixing, not a bug. 

Sure, you are as welcome to write RFC and a patch as anybody else :) So
far it's been there for about 10 years and nobody did, but that should
not be a problem. More problem would be to actually make the engine to
be able to initiate the function call (and handle all the stack frames,
make backtraces/exceptions work, etc.) without actually having any
function there but I'm sure this is possible. Actually, the patch for
default ctors that I'm finishing may give you some tools to do this.

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.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to