Re: [RFC] Bare Name Array

From: Date: Mon, 02 Jun 2014 10:27:50 +0000
Subject: Re: [RFC] Bare Name Array
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-74698@lists.php.net to get a copy of this message
On 1 Jun 2014, at 18:59, Andrea Faulds <ajf@ajf.me> wrote: > Where the key fits the profile of IS_STRING, this RFC proposes that you can do this instead: > > stringKey: 3, > > Now it’s only two characters, three including spaces, for the most common case. It makes > declaring arrays more convenient. I should note that an added bonus of passing this RFC would be that it would clear up what syntax to use for named parameters. Currently, syntax is up for debate.[0] I’m unhappy with test(foo => “bar”) because that’s inconsistent with arrays which do not quote bare word names with =>, and I think test($foo => “bar”) would be confusing. By adding the bare word colon syntax, there’d be a clear syntax that’s the same for both named parameters and arrays, if or when named parameters are implemented: foobar(4, 7, foo: 3, bar: true, “parameter with spaces” => “baz”); // Would be the same as $myParams = [4, 7, foo: 3, bar: true, “parameter with spaces” => “baz”); call_user_func_array(‘foobar’, $myParams); [0]https://wiki.php.net/rfc/named_params#syntax -- Andrea Faulds http://ajf.me/

« previous php.internals (#74698) next »