On 19 November 2014 01:50:33 GMT, Stanislav Malyshev <smalys...@gmail.com> 
wrote:
>Hi!
>
>> Is there a `.phpt` test-case or discussion backing this?
>
>Backing what? Checking if side effects happen when evaluating args of
>non-existing ctor? Probably not, since nobody ever needed it (correct
>me
>if I'm wrong). 

Quite: nobody ever needed, or expected it, or intended it.

> There are many weird scenarios of what you could do with
>PHP that are not covered by tests because nobody ever thought anybody
>would care to know what happens if you do that.

Fine. And some of those edge cases, when tested, do the wrong thing. Those are 
bugs.

>But I don't need tests to conclude it's intentional behavior - plain
>look at the code shows it very clearly, you don't make special case in
>ZEND_NEW to skip the ctor method call and write all the code around it
>if you don't mean to make special case to do just that.

I still don't have enough understanding of the engine to follow the argument 
here. That the engine skips code to dispatch to a non-existent __construct 
method doesn't seem on the face of it proof that lazy evaluation of its 
arguments was intended. It sounds more like an implementation detail that 
skipping a function dispatch also happens to skip evaluation of those 
expressions.

There is nowhere else in the language which lazily evaluates the arguments of a 
function based on the content of that function. Unused parameters, including 
those passed to an empty constructor, are always evaluated. I'm not sure why 
you're treating a parameter expression with side effects as something exotic.


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

Reply via email to