RE: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
| From: | Ford, Mike | Date: | Wed, 01 Jun 2011 09:36:21 +0000 |
| Subject: | RE: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52644@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: ekneuss@gmail.com [mailto:ekneuss@gmail.com] On Behalf Of
> Etienne Kneuss
> Sent: 01 June 2011 01:57
> To: internals@lists.php.net
> Subject: Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
>
> +1 for a short array syntax.
>
> But only if you keep it consistent, PHP has always been using => for
> key/val association, I don't see any reason to suddenly provide
> "key":
> "val", unless what you want is to confuse people.
Hear, hear and hear, hear to that!
['a': 'b'] just feels completely un-PHP-like, and I'd be totally
against it.
If the desire is to have a "native" JSON syntax so that you can eval()
imported JSON, then I'm completely anti that, too -- that's a case
where I'd far rather be explicit and use json_decode(). And since, no
matter how you slice it, you're never going to get a complete fit
between native PHP structures and JSON encoding, I don't believe you
should even try.
I just can't see the problem with saying: PHP arrays (and maybe
objects?) look like *this*, and if you want to import/export them
from/to a JSON representation, there are functions to do it like
*this*. This seems to be the perfectly sensible approach of other
languages I've used recently (although my perl is somewhat out-of-date,
and my python even more out-of-daterer and minimal at that!). Even
ECMAScript is going down the route of explicit conversion with
JSON.parse() and JSON.stringify() in ECMAScript 5!
All in all, still +1 for [1, 2=>2, 'a'=>'b'], and -several million (for
style) for any syntax involving colons.
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507 City Campus,
Portland Way, LEEDS, LS1 3HE, United Kingdom
E: m.ford@leedsmet.ac.uk T: +44 113 812 4730
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm