Re: [RFC] Default constructors

From: Date: Wed, 19 Nov 2014 09:11:50 +0000
Subject: Re: [RFC] Default constructors
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-78985@lists.php.net to get a copy of this message
On 19 November 2014 01:50:33 GMT, Stanislav Malyshev <smalyshev@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.

« previous php.internals (#78985) next »