Re: Object and Array Literals
| From: | Pierre Joye | Date: | Mon, 06 Jun 2011 16:44:04 +0000 |
| Subject: | Re: Object and Array Literals | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53047@lists.php.net to get a copy of this message | ||
hi Sean,
Please add the RFC header so we know what's the status.
Some comments:
> $a = [1,2,'three'];
I liked the existing RFC
(https://wiki.php.net/rfc/shortsyntaxforarrays) so I indeed like it
here too.
> $a = ['one': 1, 'two': 2, 'three': 'three'];
-1, did not like before, I still do not like it :) It will certainly
create some confusions and does not bring a lot of benefits. I'm not
sure how it will work either with a possible support of named
arguments. Last but not least, has anyone played with the parser to
implement it? Also the : syntax was not the preferred one either in
the short syntax RFC.
About the anonymous objects, the usage of stdclass is rare, at least
for the ones I met or use. I'm not sure about the interoperability
argument as conversions will still happen, so as someone else said, it
looks familiar but has in my opinion nothing to do with
interoperability. I'd to say a temporary -1.
Something that can change my mind is the ability to initialize an
object and its property using a similar syntax, but it sounds tricky
or not too useful (getter/setter a la c# sounds much useful for
example, if we need something in this area).
A last comment for the record here, this whole JSON-like syntax sounds
wrong to me from the beginning. JSON does not aim to be written or
read by human being. It is about exchanging data between two ends. I
don't think using it as a base for a syntax in a language is a good
thing to do.
On Sun, Jun 5, 2011 at 3:30 AM, Sean Coates <sean@seancoates.com> wrote:
> Hello.
>
> I've posted a RFC concerning Object and Array Literals on the wiki:
> https://wiki.php.net/rfc/objectarrayliterals
>
> Please read, and if you have a comment that is not already covered in the RFC, raise it here.
> I'm definitely open to discussion, but I would really love to keep this discussion civil.
>
> To get the ball rolling, here are a few points that I think we need to discuss:
>
> • Strictness of unquoted keys.
> • Support => in addition to : as a key:value separator..
> • possibility of simply not supporting the \u### syntax for Unicode characters in
> literal strings (just like the rest of PHP).
> • Should mixed-format (numeric and associative arrays) be allowed? (e.g.
> [1,'two':2, 3])
>
> I beg you to keep name-calling, conclusion-jumping, and general hostility out of this thread.
> Thanks for your attention.
>
> S
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org