Re: simpler syntax for arrays
| From: | jay | Date: | Thu, 18 Dec 2008 01:18:36 +0000 |
| Subject: | Re: simpler syntax for arrays | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42320@lists.php.net to get a copy of this message | ||
On Wed, 2008-12-17 at 16:37 -0800, Jeff Griffiths wrote:
> On 12/17/08 4:29 PM, jay wrote:
> > hi guys. i'm very new to your list so maybe something similar to my
> > proposal has been already posted somewhere at this list but really i
> > don't know how i can make the search.
> > i often pass arrays to functions/methods this way:
> >
> > myfunc(array('key1'=>'val1', 'key2'=>'val2',
> > ...));
> >
> > it's really annoying to type in 'array' every time. i suggest using a
> > simpler syntax:
> >
> > myfunc(['key1'=>'val1', 'key2'=>'val2',
> > ...]);
> >
> > like in javascript. it'd be very nice to have this handy feature.
>
> This has been discussed as a potential feature for 5.3, but was
> discussed after no small amount of flames and acrimony. here is the
> relevant wiki page:
>
> http://wiki.php.net/rfc/shortsyntaxforarrays
>
> cheers, Jeff
okey. another syntax:
myfunc($('key1'=>'val1', 'key2'=>'val2', ...));
this can be implemented just as a shortcut for the array keyword. i
think it won't be very hard to extend syntax for the dollar sign.
my idea is to shorten the syntax. no matter how it will be achieved.
regards,
jay