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.
regards,
jay
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
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
Hi Jay,
Am Donnerstag, den 18.12.2008, 03:18 +0200 schrieb jay:
[...]
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.
Obviously you preferred not to read the RFC and you did not read the
related mailinglist threads. Anyway, to shorten things a bit: it has
been discussed this year, we decided against it, things are settled.
Thanks for your attention,
Lars
Jabber: lars@strojny.net
Weblog: http://usrportage.de
Hi Jay,
Am Donnerstag, den 18.12.2008, 03:18 +0200 schrieb jay:
[...]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.
Obviously you preferred not to read the RFC and you did not read the
related mailinglist threads. Anyway, to shorten things a bit: it has
been discussed this year, we decided against it, things are settled.Thanks for your attention,
Lars
okey. it's you right to be against such simplification. but anyway it'd
be nice to have more simple and clear syntax. i hope you'll get back to
this idea in future. thanks for your replies.
regards,
jay
jay wrote:
okey. another syntax:
myfunc($('key1'=>'val1', 'key2'=>'val2', ...));
This has been discussed and rejected several times.
If you still want to be able to use this syntax you can use my patch at
http://cschneid.com/php/
including a script to convert from and to this syntax.
We use this in our production environment so the patch will be updated
for future PHP versions ;-)
If you want to use it in an environment where you cannot patch PHP you
could use our toolkit which provides an auto_prepend file with
just-in-time translation from new to old syntax.
See: http://itools.search.ch/
Regards,
- Chris
interesting idea, thanks. but unfortunately it won't help me as i really
need to pass arrays as a single argument like this:
my_func($param_1,$param_2,array(...));
i'm unaware of how to make patches for php so i wonder is it possible to
add a dollar sign shortcut for array keyword. like this:
my_func($param_1,$param_2,$(1, 2, 3));
regards,
jay
jay wrote:
okey. another syntax:
myfunc($('key1'=>'val1', 'key2'=>'val2', ...));This has been discussed and rejected several times.
If you still want to be able to use this syntax you can use my patch at
http://cschneid.com/php/
including a script to convert from and to this syntax.
We use this in our production environment so the patch will be updated
for future PHP versions ;-)If you want to use it in an environment where you cannot patch PHP you
could use our toolkit which provides an auto_prepend file with
just-in-time translation from new to old syntax.
See: http://itools.search.ch/Regards,
- Chris
Jay I. wrote:
interesting idea, thanks. but unfortunately it won't help me as i really
need to pass arrays as a single argument like this:my_func($param_1,$param_2,array(...));
You can do that. All parameters in a row with => will be merged to one
array.
You could call
myfunc($a, $b, 'foo' => "bar", 'qux' => "quux");
with our patch
You can free mix arrays and scalar values like
myfunc($a, 'b' => "foo", $c, 'd' => "bar", ...);
which is the same as
myfunc($a, array('b' => "foo"), $c, array('d' => "foo"), ...);
And if you need two separate arrays in a row you can still go back to
having array() for the second one (but we avoid parameter lists like that).
Ok, enough plugging of that syntax on the list, further replies will be
off-list ;-)
- Chris