Re:Critiquing Facebook's new PHP spec
by arenaninja on Thursday July 31, 2014 @02:08PM
(#8115881)
I think your latter point is part of my confusion. Is this a proposal for what PHP should be or what it currently is? I'm as excited as anyone for the upcoming jPHP but, array bug aside, breaking BC is huge in PHP. I've used the __destruct method plenty of times to automate DB changes without explicitly calling a function to save those changes
I disagree. They underspecified the language, so it still technically represents the current state of the Zend implementation of PHP.
(I take no position on RAII being useful or not, I don't write PHP for a living).
It's in direct conflict with the PHP manual:
http://php.net/manual/en/language.oop5.decon.php#language.oo...
"PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence."
It's very common to rely on this behavior to do cleanup as PHP did not have a finally clause (like C++) until recently.
I think we're talking at cross-purposes. I'm just saying that because it's underspecified, the Zend engine can be both accurate to what's in the PHP manual, and to what's in the spec.
Anyway, it's a slightly pedantic point, so I'm probably not contributing much to the conversation here :)
I understand your point. The spec as written means the Zend Engine itself is accurate the spec. The problem is the spec isn't accurate to the language, as it exists, in the wild. Existing correct and valid PHP code executed to this spec will behave incorrectly. Therefore, it's not really a PHP spec.
PHP Code > PHP Spec > PHP Engine
The spec, as it stands, is flawed. Any removal of RAII should be left to major version (e.g. PHP7). Since this spec is meant to represent the current state of PHP, it's completely incorrect in this area.