Re: internals Digest 24 Oct 2003 20:08:45 -0000 Issue 194
| From: | Christian Schneider | Date: | Fri, 24 Oct 2003 21:13:34 +0000 |
| Subject: | Re: internals Digest 24 Oct 2003 20:08:45 -0000 Issue 194 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4974@lists.php.net to get a copy of this message | ||
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