Re: [RFC] Named parameters

From: Date: Fri, 06 Sep 2013 18:11:31 +0000
Subject: Re: [RFC] Named parameters
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
George Bond wrote:
> Then the double-dollar syntax would seem the obvious choice to me:
> foo( $$param => 'whatever' );

> Which is no less readable than anywhere else the double-dollar is
> allowed...  :-p

For the simple case I agree having double $$ signs is not that bad, but it
would get nasty for anything other than a simple variable. e.g. if the
param name was in an array:

$searchKeys[] = 'firstParameter'
$searchValues[] = 25;

foo( ${$searchKeys[0]} => $searchValues[0] );

which is definitely less legible than:

foo( $searchKeys[0] => $searchValues[0] );

cheers
Dan


On Fri, Sep 6, 2013 at 6:44 PM, George Bond
<[email protected]>wrote:

> Regarding variable parameter names; if the syntax was:
>
> function foo( $firstParameter ) { ... }
> foo( $firstParameter=> 'foo' );
>
> Then the double-dollar syntax would seem the obvious choice to me:
>
> function foo( $firstParameter ) { ... }
> $param = 'firstParameter';
> foo( $$param => 'whatever' );
>
> Which is no less readable than anywhere else the double-dollar is
> allowed...  :-p
>
> --G
>


Thread (46 messages)

« previous php.internals (#68920) next »