** Reply to note from Markus Fischer <[EMAIL PROTECTED]> Fri, 11 Jan 2002 
12:48:15 +0100
>   
> What other way do we have to specify arbitray optional parameters
> without an ordering? Teh disadvantage of optional parmeters is when
> you need to only set the last one, you'll have to define all
> preceding optional parameters too.


Consider allowing this:



function foo( $one=1, $two=2, $three=3 ) {

echo "$one $two, $three";
}

foo( ,,5 );   # prints: 1 2 5



No value between commas in the parm list says take the default.
Required params must be filled in, but not specifying a value for an
optional parm takes the default from the function header.

It still requires the parms to be in the correct order, but you can
pick and chose which optional parms you want non-default values for.
The disadvantage is having to have the right number of commas before
your values, but at least you don't have to list all the defaults. (and
prevent yourself from being able to change a default just by changing
the function itself.)

The idea is stolen from HP's MPE operating system which I was sorry to
see depreciated recently.


Rick

Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to