Re:New Features in PHP 5.6
by BugBrother on Friday January 17, 2014 @01:51PM
(#7077639)
The Perl way is to declare minimum language version to execute a code file. E.g. use v5.12;
Then you can do extensions [even changing central functionality] in a sane way, with backward compatibility. (A language implementation need to implement deprecated features for older versions, of course.)
I agree with your point re APIs.
I've had this idea of minimum language version as well. In PHP it should probably done at the namespace level. It doesn't even need new language syntax, just a function to declare the minimum PHP version for a namespace and child namespaces:
set_minimum_version('My/New/Component', '5.7.8');
This could be called in the component itself or maybe by a composer autoloader. Then PHP components that expect different version could live together.The big problem, as you mentioned, is that the interpreter would have to maintain all the deprecated features and behavior for older versions and that would make development and maintenance of PHP much more complicated.
That's what we do with Composer, we set the minimum PHP version.
The correct approach is slow and steady improvements. I suspect standard library improvements will come not by renaming existing functions but by adding new API.