So why am I saying all of this? Well, PHP up until 4 had a reputation
for lots of bad coding style, spaghetti code, etc. With PHP 5 and
better OOP, this reputation has lessened, especially with the great
libraries out there (Zend Framework, Kohana, symfony, etc.) But there
is still a problem. We (or at least I) would want PHP 6's reputation
to be even better, and the reputation is largely based on how
maintainable and cost-effective the code is, which is written by
programmers actually using PHP. Blaming newbie programmers is one
thing, and may even have some truth to it (PHP is simple - thus
attracts newbies) but it's always good for a language to steer you in
the right direction by default, and make it easier to write
maintainable code.
PHP has a great opportunity to do this, by implementing a very simple
change, turning all current PHP 5 code, and all code that will be
written in the future, into maintainable code. Moreover, it won't
break any existing code, like some other additions to PHP 6 might do.
This one simple tweak will make PHP 6 code much more reusable and
maintainable, just like namespace support will potentially make future
PHP code more interoperable without having to write
Artificial_Namespace_Class, like ZF and PEAR do.
Thankfully it's rather unlikely that someone would use a variable for the name anyway.
Where this will bite people is when they do meta programming with functions that process functions and function signatures.
Maybe I'm missing something, but I find this to be another tragically missed opportunity. It's just unnecessary friction where there didn't need to be any, which makes me sad. At least they can add variable name support someday, because it's easier to allow something restricted than restrict something that used to work. Hopefully there is a "good reason" for this oversight.
i'm not sure it's a good thing readability wise. I would have liked to see struct definitions + adhoc struct definitions and destructuring instead of that.
Some frameworks like Symfony relied too much on shoving unstructured array options as arguments though, so if it helps making API strictier...
I don't understand why pretty much no language does that these days. I think the argument is that your IDE should do this, and it does in some cases, but still...
If you have this there's really no need for named arguments anymore. If you add features to your de-structuring, your "named arguments" will have them too (things missing for JS specifically: optional objects, TS support to specify types for the destructured objects inline instead of repeating the entire thing).
Mixing implicit positional and named parameters is a misfeature. The named parameters should have a distinct syntax like other systems do, e.g. :$ twigil.
https://www.mail-archive.com/internals@lists.php.net/msg4587...
Excerpt of the proposal:
So why am I saying all of this? Well, PHP up until 4 had a reputation for lots of bad coding style, spaghetti code, etc. With PHP 5 and better OOP, this reputation has lessened, especially with the great libraries out there (Zend Framework, Kohana, symfony, etc.) But there is still a problem. We (or at least I) would want PHP 6's reputation to be even better, and the reputation is largely based on how maintainable and cost-effective the code is, which is written by programmers actually using PHP. Blaming newbie programmers is one thing, and may even have some truth to it (PHP is simple - thus attracts newbies) but it's always good for a language to steer you in the right direction by default, and make it easier to write maintainable code.
PHP has a great opportunity to do this, by implementing a very simple change, turning all current PHP 5 code, and all code that will be written in the future, into maintainable code. Moreover, it won't break any existing code, like some other additions to PHP 6 might do. This one simple tweak will make PHP 6 code much more reusable and maintainable, just like namespace support will potentially make future PHP code more interoperable without having to write Artificial_Namespace_Class, like ZF and PEAR do.