On Jan 12, 2006, at 7:22 AM, Ilia Alshanetsky wrote:

Aidan Lister wrote:
As useful functions tend to increase in complexity over time, often so
does the number of parameters.

It soon gets to the point where function calls look like:
foo(true, false, false, false, false, true)
The rest of the parameters being required to be supplied, with their
default value, when the user is only interested in changing the last
option.

Sure, you can fall back to associative array parsing. However, I feel it
lacks the rigor that named parameters can give. Named parameters also
give a clean method for the user to see the available options, rather
than reading through source code.

What exactly do you find lack about associative arrays?

To put the shoe on the other foot, what exactly do you find lacking about named parameters so that you'd prefer to use the more syntactically complex and less sophisticated array method? Quite frankly, implementing named parameters is sort of a no-brainer; I understand a reluctance to implement it based on time/effort considerations, but for some of the core devs to actually defend not implementing it based on a design decision is weird.

Why named parameters? Because like with normal parameters/arguments, you must specify required parameters. An associative array is not enforced by the language -- you have to manually check that the array has the required parameters and manually throw an error/exception. That's...stupid. Plus, with the array there is no language-based documentation for the parameters -- all that the function/method signature specifies is just one array parameter. That's also stupid.

PHP is all about using a simple means to an end and getting the job done. Named parameters makes coding easier, not harder. So why defend keeping it out of the language?

Regards,

Jared

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

Reply via email to