Re: [RFC] Default constructors

From: Date: Tue, 18 Nov 2014 23:20:49 +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-78971@lists.php.net to get a copy of this message
On 18/11/2014 23:11, Stanislav Malyshev wrote:
"Been in PHP for a very long time" != "how it was intended to work". Can
you explain why this would be the intention of anyone designing the language? Of course, been for a long time is not the same as intended. But if you look at how ZEND_NEW is done, it's clear it's intended. And the reason is simple - if there's no function, it's not really possible to initiate a function call and handle it properly, since the engine expects certain data there and there's nothing to provide that data. So, ZEND_NEW having no function just skips the whole function call thing altogether.
This is where I struggle: to me, the "++$b" in "foo(++$b)" or "new Foo(++$b)" isn't part of the function call; it's a statement that has to be evaluated *before* the function call can happen. If a fatal error is being raised, it makes (some) sense to skip that evaluation, but if execution is continuing, it seems perfectly natural for that expression to be evaluated even if its result is discarded.
If you think the decision was wrong and it can be done better - cool, let's see the patch.
I'm happy to accept that this is a low-priority, hard-to-fix, bug. I just don't see that it can be justified as a feature. -- Rowan Collins [IMSoP]

« previous php.internals (#78971) next »