Daniel Crookston wrote:
some_function($a, 'B', :check TRUE)

function some_function($first, $second, :check $key1 = FALSE, :foo $key2)

First of all: I guess it is too early to start the discussion about named parameters again.


As much as I think named parameters are an interesting concept I don't like this solution for its syntax and static semantics.

If you are still interested in what solution we chose here then read below the line, otherwise please ignore the rest and don't flame me ;-)

---------------------------------------------------------------------

I'm still in favor of an approach we are using here where you can pass associative arrays without array():

some_function($a, "B", 'check' => true);

[ equivalent to some_function($a, "B", array('check' => true)); ]
and use

function some_function($first, $second, $param)
{
        if ($param['check'])
                ...
}

[ or extract($more) inside some_function if you prefer that ].

Patches for php4 and php5 can be found at
http://cschneid.com/php/php4/function_call_named_parameters.patch
and
http://cschneid.com/php/php5/function_call_named_parameters.patch
respectively

There is also a tool called convertsyntax.php at
http://cschneid.com/php/
which converts between old and new syntax.

Have fun,
- Chris

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



Reply via email to