Re: Named parameters, was Re: Syntactic improvement to array

From: Date: Mon, 05 Feb 2007 12:54:37 +0000
Subject: Re: Named parameters, was Re: Syntactic improvement to array
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-27806@lists.php.net to get a copy of this message
Richard Quadling wrote: >> Argh! Reading such a line, I think of named parameters, not an array. That's exactly what we are emulating this way ;-) > I agree with Francois here. Other than looking STRONLY like named > parameters, surely there is a flaw if a declaration is ... > > function convert(array $from, array $to) > > If the calling code is ... > > convert('foo' => $foo, 'bar' => $bar, ...) > > where is the boundaries for the 2 arrays? Our patch is greedy, i.e. it collects as much as possible into one array. If you want to do this you need an explicit array() on the second set of parameters. That's magical, non-obvious and evil but we tend to have one $p array for all named parameters only, why would you want more than one parameter here anyway? ;-) But I realize that's too much off the beaten path for The List and I'm not even sure why I mentioned it. So please ignore it and go back to Andi's proposal :-) - Chris

« previous php.internals (#27806) next »