Michael Walter wrote:
(the common) way of faking named parameters, you rely on a) hash lookups at execution time (for _every_ call) and b) on manually dealing with default values.

I'd even be happy to accept these two drawbacks but the ugliness of the array() solution is what I'd like to get rid of.


Something like either
foo('x' => 'x-value', 'y' => 'y-value);
or
foo($x => 'x-value', $y => 'y-value');
or
foo(x:'x-value', y:'y-value');
or a mix of one of these solutions would be really handy in writing readable code.


One thing which would make it really powerful for my purpose would be if I don't have to declare all possible parameters to my function, i.e. a way for foo() to find out what arguments were passed to it (name and value). Something like treating the whole parameter list as an array definition so that (using the first of the above syntax versions)
foo('x' => 'x-value', 'y' => 'y-value', 'z-value');
would basically be the same as
foo(array('x' => 'x-value', 'y' => 'y-value', 'z-value'));
but more readable (and writable).


I think of the parameter list as a kind of an array anyway, that's why I think both array()-less named parameters and dangling comma at the end should be allowed.

- Chris

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



Reply via email to