Andi Gutmans wrote:
In my opinion, as Ilia stated passing an associative array does the job quite well for the use-case where named arguments would be useful. Sure it might be a tad-bit sexier that you don't have to write array() but the truth is that the implementation would probably still use an array. Unlike Ada which has extremely strict typing, in PHP in most cases we wouldn't be able to optimize away the named parameters, meaning that we'd probably do the array() trick anyway.

You are argueing from a php internal level. Named parameters are useful for situations where you have alot of parameters. I think people have shown that this may not be the common case, but its still very much real.

People have shown ways to handle default values fairly efficiently. However this still dances around the language level documentation.

It also dances around the need for error handling entirely. Of course you could also hack in some checks using array_diff() to determine if there are any unwanted parameters and then trigger an error.

Now we have not even addressed the potential for type hinted parameters.

However this means adding a fair amount of LOC, that are much less obvious to read. Performance in this case is not the main factor, but if oyu add in a call to array_diff() with a !empty() if statement I think its hard to argue that the performance would be equal either.

Also contrary to alot of the things we have added since php 5.x I think this language feature would be much more obvious and easy to grasp even without reading any documentation on it. As such it very much fits the PHP style and has very little risk of obfuscating the language.

Now obviously there would have to be someone to implement it, but I see no "design" reason to not allow this feature in.

regards,
Lukas

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to