Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Jun 1, 2011, at 7:35 AM, Derick Rethans wrote: >> 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. > Yes, definitely "=>" vs. ":" in any case. +1 to this. -- Gwynne -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Wed, 1 Jun 2011 10:27:36 -0400, Sean Coates wrote: This discussion seems to lack real-world examples… Derick wrote: I'm still -1 on it. It makes absolutely unreadable code (yes, also in JavaScript with f.e. MongoDB). Here's an actual snippet from my production code (which interfaces with ElasticSearch): http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html If you consider this readable, you're fare more literate than I will ever be (-: Imho, this example just lacks a good OO abstraction (Query Builder) that has a toMongoQueryArray() method. … Gustavo wrote: $a[array()]; is much more clear than $a[[]] Anyone who considers themselves skilled enough to participate in a language-forming discussion like this one should also have the prerequisite ability to determine that using an [empty] array as an array key is a horrible idea, and they deserve whatever weirdness ensues. IMO. S -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
>> Here's an actual snippet from my production code (which interfaces with >> ElasticSearch): >> http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html >> >> If you consider this readable, you're fare more literate than I will ever be >> (-: > > Using JSON syntax would only "maybe" make it more readable, and then > only because you would probably not format it on so many lines ;-) For gits and shiggles I converted it to short array syntax. I structure my arrays much like Sean does and I was of the opinion that a shorter syntax would not improve the readability much. I have to admit I do like the way the short syntax with the : separator looks, though the => separator is not bad on the eyes either. Converted snippets: Using => separator: http://paste.roguecoders.com/p/8c653602dee96b87f566a29b78aa4daa.html Using : (JSON) separator: http://paste.roguecoders.com/p/b117894e85b6f980b8390bc2828ca227.html -- Herman Radtke hermanrad...@gmail.com | http://hermanradtke.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
Would it be possible to have a vote on the various options being proposed here? I think JSON syntax is definitely more concise and easier to type, as well as more convenient -- but I don't think it makes sense for PHP without changing how arrays work (I'm all for that, but that's a different discussion) So for me, I'm -1 on a fudged JSON syntax with key: value syntax, even though I prefer that syntax over => But I'm => on being able to simply drop 'array' from array delcarations. I have a third option that I'm sure no one but me would like, what if we had some way to designate an item as an object, instead of an associative array? This could be handled either with : instead of => or {} instead of (). {} instead of () seems to make more sense. ('arraykey' => {'property': 'value'}) Mimicking JSON just seems pointless if we can't actually provide any benefit to doing so, since we'd still either have to differentiate between object/array *and* load via eval() (-) or json_decode() (+) This RFC just seems premature, or at least doesn't offer enough voting options. On Jun 1, 2011, at 10:56 AM, Rasmus wrote: > On 06/01/2011 08:00 AM, Justin Carmony wrote: >> In all seriousness, there is a vast majority of PHP developers who are not >> represented on this list. I was surprised to see someone mentioning for >> calling for another vote so soon after this discussion came up. Perhaps >> instead of debating on readability and usefulness, we actually do some >> research with major PHP users to get their opinions? I'm not saying we >> should have every PHP user in the world vote, but there are talented PHP >> developers who are not apart of the core that have valid and insightful >> views and opinions. >> >> So what I would first propose is we finalize the RFC because right now it is >> has two options, and doesn't deal with objects. I think everyone is starting >> to agree "=>" is much more uniform than ":", so lets drop the ":" from the >> RFC. >> >> Then, lets request some feedback from reputable PHP developers, like authors >> of popular frameworks and PHP solutions. This way we can get some real input >> from people who are not on the internals email list. This can help those who >> make the decision on whether or not to accept the RFC aware not only of >> their own personal opinion and preferences, but the opinions and preferences >> of the PHP community as a whole. >> >> I know I'm newer to the list, and don't want to step on any toes, but I >> think the RFC process could really benefit from getting this type of >> feedback. > > I think it is well understood that PHP internals discussion happens on > this internals mailing list. It is not a restricted list in any way. > Anybody is able to participate here if they want their voice heard. > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On 06/01/2011 08:00 AM, Justin Carmony wrote: > In all seriousness, there is a vast majority of PHP developers who are not > represented on this list. I was surprised to see someone mentioning for > calling for another vote so soon after this discussion came up. Perhaps > instead of debating on readability and usefulness, we actually do some > research with major PHP users to get their opinions? I'm not saying we should > have every PHP user in the world vote, but there are talented PHP developers > who are not apart of the core that have valid and insightful views and > opinions. > > So what I would first propose is we finalize the RFC because right now it is > has two options, and doesn't deal with objects. I think everyone is starting > to agree "=>" is much more uniform than ":", so lets drop the ":" from the > RFC. > > Then, lets request some feedback from reputable PHP developers, like authors > of popular frameworks and PHP solutions. This way we can get some real input > from people who are not on the internals email list. This can help those who > make the decision on whether or not to accept the RFC aware not only of their > own personal opinion and preferences, but the opinions and preferences of the > PHP community as a whole. > > I know I'm newer to the list, and don't want to step on any toes, but I think > the RFC process could really benefit from getting this type of feedback. I think it is well understood that PHP internals discussion happens on this internals mailing list. It is not a restricted list in any way. Anybody is able to participate here if they want their voice heard. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
In all seriousness, there is a vast majority of PHP developers who are not represented on this list. I was surprised to see someone mentioning for calling for another vote so soon after this discussion came up. Perhaps instead of debating on readability and usefulness, we actually do some research with major PHP users to get their opinions? I'm not saying we should have every PHP user in the world vote, but there are talented PHP developers who are not apart of the core that have valid and insightful views and opinions. So what I would first propose is we finalize the RFC because right now it is has two options, and doesn't deal with objects. I think everyone is starting to agree "=>" is much more uniform than ":", so lets drop the ":" from the RFC. Then, lets request some feedback from reputable PHP developers, like authors of popular frameworks and PHP solutions. This way we can get some real input from people who are not on the internals email list. This can help those who make the decision on whether or not to accept the RFC aware not only of their own personal opinion and preferences, but the opinions and preferences of the PHP community as a whole. I know I'm newer to the list, and don't want to step on any toes, but I think the RFC process could really benefit from getting this type of feedback. Justin Carmony On Jun 1, 2011, at 8:37 AM, Philip Olson wrote: > > On Jun 1, 2011, at 7:30 AM, Ilia Alshanetsky wrote: > >> On Wed, Jun 1, 2011 at 4:27 PM, Sean Coates wrote: >>> This discussion seems to lack real-world examples… >>> >>> Derick wrote: I'm still -1 on it. It makes absolutely unreadable code (yes, also in JavaScript with f.e. MongoDB). >>> >>> >>> Here's an actual snippet from my production code (which interfaces with >>> ElasticSearch): >>> http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html >>> >>> If you consider this readable, you're fare more literate than I will ever >>> be (-: >> >> Using JSON syntax would only "maybe" make it more readable, and then >> only because you would probably not format it on so many lines ;-) > > Maybe that could be a contest. Who can make this the prettiest, using either > a proposed or current syntax. :) > > Regards, > Philip > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Jun 1, 2011, at 7:30 AM, Ilia Alshanetsky wrote: > On Wed, Jun 1, 2011 at 4:27 PM, Sean Coates wrote: >> This discussion seems to lack real-world examples… >> >> Derick wrote: >>> I'm still -1 on it. It makes absolutely unreadable code (yes, also in >>> JavaScript with f.e. MongoDB). >> >> >> Here's an actual snippet from my production code (which interfaces with >> ElasticSearch): >> http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html >> >> If you consider this readable, you're fare more literate than I will ever be >> (-: > > Using JSON syntax would only "maybe" make it more readable, and then > only because you would probably not format it on so many lines ;-) Maybe that could be a contest. Who can make this the prettiest, using either a proposed or current syntax. :) Regards, Philip -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Wed, Jun 1, 2011 at 4:27 PM, Sean Coates wrote: > This discussion seems to lack real-world examples… > > Derick wrote: >> I'm still -1 on it. It makes absolutely unreadable code (yes, also in >> JavaScript with f.e. MongoDB). > > > Here's an actual snippet from my production code (which interfaces with > ElasticSearch): > http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html > > If you consider this readable, you're fare more literate than I will ever be > (-: Using JSON syntax would only "maybe" make it more readable, and then only because you would probably not format it on so many lines ;-) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
This discussion seems to lack real-world examples… Derick wrote: > I'm still -1 on it. It makes absolutely unreadable code (yes, also in > JavaScript with f.e. MongoDB). Here's an actual snippet from my production code (which interfaces with ElasticSearch): http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html If you consider this readable, you're fare more literate than I will ever be (-: … Gustavo wrote: > $a[array()]; > > is much more clear than > > $a[[]] Anyone who considers themselves skilled enough to participate in a language-forming discussion like this one should also have the prerequisite ability to determine that using an [empty] array as an array key is a horrible idea, and they deserve whatever weirdness ensues. IMO. S -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On 2011-05-31, Brian Moon wrote: > https://wiki.php.net/rfc/shortsyntaxforarrays > > PHP SVN account holder voters >= > Pro: Andrei Zmievski, Andi Gutmans, Pierre Joye, Rasmus Lerdorf, > Stanislav Malyshev, Brian Moon, Kalle Sommer Nielsen, Edin Kadribasic > > Contra: Antony Dovgal, Derick Rethans, Jani Taskinen, Lokrain, Felipe > Pena, Lukas Kahwe Smith, Marcus Boerger, David Soria Parra, Johannes > Schl??ter, Maciek Sokolewicz, Philip Olson, Ilia Alshanetsky, Daniel > Brown, Jochem Maas, Hannes Magnusson, David Coallier +1 from me now after reviewing the discussion and the patch. But I would like to see ['x' => 2] instead of ['x': 2] as => was always reserved for assoc in PHP (as mentioned earlier in the thread). -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Wed, 1 Jun 2011, Etienne Kneuss wrote: > +1 for a short array syntax. I'm still -1 on it. It makes absolutely unreadable code (yes, also in JavaScript with f.e. MongoDB). > 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. Yes, definitely "=>" vs. ":" in any case. cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
Using an explicit json_decode is actually a huge problem. It isn't just hard to write encoded stuff into strings, it is a security issue because you have to encode the values that you are then encoding into JSON. For example: json_decode('{a: "a", b: "b", foo: "'.$_POST['foo'].'"}'); // !!! Security problem !!! Value injection is possible with a properly formed 'foo' parameter in the post. To avoid this, you have to do the following: json_decode('{a: "a", b: "b", foo: '. json_encode($_POST['foo'].'}'); Compare that clunky monstrosity to: {a: "a", b: "b", foo: $_POST['foo']}; Remember that this syntax is less about constants and more about binding values into some structure. As a C++ programmer I whole heartedly agree with the confusion point, but as a PHP developer I don't. Basically every PHP developer is going to be familiar with JavaScript, because it is also a web language. Go to oDesk.com, and you can't find a developer looking for PHP work who doesn't know how to work with jQuery or similar. Browser fragmentation makes jQuery or something similar almost essential for modern web development, and JSON is used extensively in all of these frameworks. Any PHP developer worth a dime will know exactly what they are looking at. I agree that [a: 'b'] would be totally wrong. This doesn't look like PHP OR JSON, and is likely to cause confusion. If [a=>$b] is the only syntax people can agree on, I can live with that, but IMO that syntax will actually create MORE confusion than just allowing pure JSON (opinion informed by trying to get new devs up to speed on a project that uses MongoDB.) John Crenshaw Priacta, Inc. -----Original Message- From: dukeofgaming [mailto:dukeofgam...@gmail.com] Sent: Wednesday, June 01, 2011 5:51 AM To: Ford, Mike Cc: Etienne Kneuss; internals@lists.php.net Subject: Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux) After that argument, I think I'm against ":" now too. +1 to "=>" Could "{ }" be implemented for objects too then?. Regards, David On Wed, Jun 1, 2011 at 4:36 AM, Ford, Mike wrote: > > -----Original Message- > > From: ekne...@gmail.com [mailto:ekne...@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.f...@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 > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
Big +1 on the patch. The ":" although a better choice would be asymmetric to how its done inside array(). On Wed, Jun 1, 2011 at 11:50 AM, dukeofgaming wrote: > After that argument, I think I'm against ":" now too. +1 to "=>" > > Could "{ }" be implemented for objects too then?. > > Regards, > > David > > On Wed, Jun 1, 2011 at 4:36 AM, Ford, Mike wrote: > >> > -Original Message- >> > From: ekne...@gmail.com [mailto:ekne...@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.f...@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 >> > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
After that argument, I think I'm against ":" now too. +1 to "=>" Could "{ }" be implemented for objects too then?. Regards, David On Wed, Jun 1, 2011 at 4:36 AM, Ford, Mike wrote: > > -Original Message- > > From: ekne...@gmail.com [mailto:ekne...@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.f...@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 >
RE: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
> -Original Message- > From: ekne...@gmail.com [mailto:ekne...@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.f...@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
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Tue, May 31, 2011 at 9:27 PM, Rasmus wrote: > On 05/31/2011 05:42 PM, dukeofgaming wrote: > > > I'm afraid that if ":" is associated with the JSON interop argument and > the > > later is discarded then ":" will be discarded too, much like what > happened > > with the echo shortcut (" idea > > of JSON interop could be taken to another RFC and get less noise and > better > > ideas as a separate topic. > > > -Rasmus > Yep, I know, and thank you very much for that (I did see your commit a couple of hours after you posted it). I think there was a lot of confusion and fear (myself included) when "" is the only thing left to decide on this proposal. I was thinking that if ":" was to be introduced, perhaps "array('a':'A',...)" should also be added for consistency, and that is extra work. In my opinion adopting ":" would be nice, but it would also be noise for the developer community, perhaps good noise but noise nonetheless. The healthy thing to do here IMHO, would be putting introduction of ":" as a separate RFC, perhaps part of a JSON interoperability RFC, but as Adam just replied, PHP is not JSON and "=>" is a very fundamental thing to change, so I have mixed feelings about this. Also, can we agree on the topic of introducing "{ }" for objects to the proposal?. Best regards, David
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On 1 June 2011 08:57, Etienne Kneuss wrote: > +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. Agreed here: +1 for short array syntax using =>; -0 for short array syntax using colons. PHP isn't JSON, and I'd rather be consistent with previous PHP syntax, given the choice. Adam -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On 05/31/2011 05:42 PM, dukeofgaming wrote: > I'm afraid that if ":" is associated with the JSON interop argument and the > later is discarded then ":" will be discarded too, much like what happened > with the echo shortcut (" of JSON interop could be taken to another RFC and get less noise and better > ideas as a separate topic. http://www.php.net/unsub.php
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. On Wed, Jun 1, 2011 at 02:42, dukeofgaming wrote: > On Tue, May 31, 2011 at 7:29 PM, Dan Birken wrote: > >> +1 >> >> To be honest, ['a': 'b'] or ['a' => 'b'] is so much better than array('a' >> => >> 'b') for general use I don't even care which one is picked, as long as one >> of them is picked. >> >> -Dan >> > > +1 to that too. Even when I've never liked that much "=>" and would love to > see ":" make an entrance instead . > > I'm afraid that if ":" is associated with the JSON interop argument and the > later is discarded then ":" will be discarded too, much like what happened > with the echo shortcut (" of JSON interop could be taken to another RFC and get less noise and better > ideas as a separate topic. > > Regards, > > David > -- Etienne Kneuss http://www.colder.ch -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
On Tue, May 31, 2011 at 7:29 PM, Dan Birken wrote: > +1 > > To be honest, ['a': 'b'] or ['a' => 'b'] is so much better than array('a' > => > 'b') for general use I don't even care which one is picked, as long as one > of them is picked. > > -Dan > +1 to that too. Even when I've never liked that much "=>" and would love to see ":" make an entrance instead . I'm afraid that if ":" is associated with the JSON interop argument and the later is discarded then ":" will be discarded too, much like what happened with the echo shortcut ("
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
+1 To be honest, ['a': 'b'] or ['a' => 'b'] is so much better than array('a' => 'b') for general use I don't even care which one is picked, as long as one of them is picked. -Dan On Tue, May 31, 2011 at 3:43 PM, Marcel Esser wrote: > From the perspective of someone that's just trying to get stuff done: > > $packet = array('response' => array('status' => 1,'message' => ''),'data' > => array('id' => 1, 'username' => 'john doe')); > > $packet = ['response': ['status': 1, 'message': '', 'data': ['id': 1, > 'username': 'john doe'] ] ]; > > The clarity improvement above is an exponential function that gets better > and better the more deeply nested you are. I don't know anyone that needs > the ability to support full JSON notation in PHP, but there are entirely too > many deeply nested array() declarations with lots of tabs in our lives, > especially when we start working with things like JSON and/or Mongo or xyz. > > That's all I wanted to say to this. > > Cheers, > M. > > -- > Marcel Esser > Vice President of Engineering, CROSCON > +1 (202) 470-6090 > marcel.es...@croscon.com > > Before printing this e-mail, please consider the rainforest. >
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
Yeah, you'll note I am not actually advocating making a full JSON implementation in the PHP language. However, as per your point, JSON is no longer just a machine interchange format. It's many other things these days, including a query definition protocol. It's unlikely that the number of systems that use JSON as a descriptor or filter will decrease in the near future; many people are implementing JSON subsets or supersets in this format. And, as mentioned, that turns into a ton of typing when you start getting deeply nested - in a way that is not nearly as straight-forward as functionally identical JSON-like notation. So, considering all that, there is no real reason that I can see why it shouldn't be possible to facilitate the developer with an ability to more easily express these more complicated, nested examples. That's why everyone in Mexico was cheering. - M. -- Marcel Esser Vice President of Engineering, CROSCON +1 (202) 470-6090 marcel.es...@croscon.com Before printing this e-mail, please consider the rainforest. On 5/31/11 7:30 PM, "Michael Shadle" wrote: >I've always considered json an awesome machine to machine interchange >format (the most efficient one) but not the easiest to read for >configuration or manually defining anything. > >I see nothing wrong with the initial example. Has worked well for years. >:) > > >On May 31, 2011, at 3:43 PM, Marcel Esser >wrote: > >> From the perspective of someone that's just trying to get stuff done: >> >> $packet = array('response' => array('status' => 1,'message' => >>''),'data' => array('id' => 1, 'username' => 'john doe')); >> >> $packet = ['response': ['status': 1, 'message': '', 'data': ['id': 1, >>'username': 'john doe'] ] ]; >> >> The clarity improvement above is an exponential function that gets >>better and better the more deeply nested you are. I don't know anyone >>that needs the ability to support full JSON notation in PHP, but there >>are entirely too many deeply nested array() declarations with lots of >>tabs in our lives, especially when we start working with things like >>JSON and/or Mongo or xyz. >> >> That's all I wanted to say to this. >> >> Cheers, >> M. >> >> -- >> Marcel Esser >> Vice President of Engineering, CROSCON >> +1 (202) 470-6090 >> marcel.es...@croscon.com >> >> Before printing this e-mail, please consider the rainforest. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
I've always considered json an awesome machine to machine interchange format (the most efficient one) but not the easiest to read for configuration or manually defining anything. I see nothing wrong with the initial example. Has worked well for years. :) On May 31, 2011, at 3:43 PM, Marcel Esser wrote: > From the perspective of someone that's just trying to get stuff done: > > $packet = array('response' => array('status' => 1,'message' => ''),'data' => > array('id' => 1, 'username' => 'john doe')); > > $packet = ['response': ['status': 1, 'message': '', 'data': ['id': 1, > 'username': 'john doe'] ] ]; > > The clarity improvement above is an exponential function that gets better and > better the more deeply nested you are. I don't know anyone that needs the > ability to support full JSON notation in PHP, but there are entirely too many > deeply nested array() declarations with lots of tabs in our lives, especially > when we start working with things like JSON and/or Mongo or xyz. > > That's all I wanted to say to this. > > Cheers, > M. > > -- > Marcel Esser > Vice President of Engineering, CROSCON > +1 (202) 470-6090 > marcel.es...@croscon.com > > Before printing this e-mail, please consider the rainforest. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
From the perspective of someone that's just trying to get stuff done: $packet = array('response' => array('status' => 1,'message' => ''),'data' => array('id' => 1, 'username' => 'john doe')); $packet = ['response': ['status': 1, 'message': '', 'data': ['id': 1, 'username': 'john doe'] ] ]; The clarity improvement above is an exponential function that gets better and better the more deeply nested you are. I don't know anyone that needs the ability to support full JSON notation in PHP, but there are entirely too many deeply nested array() declarations with lots of tabs in our lives, especially when we start working with things like JSON and/or Mongo or xyz. That's all I wanted to say to this. Cheers, M. -- Marcel Esser Vice President of Engineering, CROSCON +1 (202) 470-6090 marcel.es...@croscon.com Before printing this e-mail, please consider the rainforest.
[PHP-DEV] Re: RFC: Short syntax for Arrays (redux)
Voting in favor of a short syntax, as a mostly userland dev, seems a no-brainer, but both suggested syntaxes and patches are rather unnatural: they attempt to mimic JSON syntax, but do not go the whole way. The second syntax, possibly more natural to PHP devs, might well be more trouble than it is worth, though, as it is quite close to the existing ()-braced format, only with [], thus possibly disturbing new users of the language. The first syntax, being more remote from the normal array() initializer format, might well be less disturbing. But in that case, it might just as well be completely handle a complete JSON initialization format, without the need for a json_decode(). Le Tue, 31 May 2011 20:42:18 +0200, Brian Moon a écrit: https://wiki.php.net/rfc/shortsyntaxforarrays Since this was brought again recently by Rasmus (http://markmail.org/message/fx3brcm4ekh645se) and on Twitter where several people including Andi chimed in on it and Ilia seemed to reverse his thoughts as well (with caveats), I thought I would start a real thread about it. The reason the RFC stalled was stated as: "This patch will not be accepted because slight majority of the core developers voted against. Though if you take a accumulated mean between core developers and userland votes seems to show the opposite it would be irresponsible to submit a patch witch is not supported or maintained in the long run." So, the PHP users want it, but too many PHP core devs did not want it or did not see the use of it. From rereading the mailing list archive, most had the tone of "I don't see a reason for it." I was in that camp in 2003 when it first came up. However, with the emergence of JSON and systems that use JSON as an interface, this type of syntax would be most welcome in the day to day life of a PHP developer. I would prefer (as Rasmus pointed out) not to start a long discussion about it. Primarily I would be curious if anyone on the lists (from the RFC wiki page) below would like to change your vote or if you are not listed below and would like to be counted, that would be great too. PHP SVN account holder voters = Pro: Andrei Zmievski, Andi Gutmans, Pierre Joye, Rasmus Lerdorf, Stanislav Malyshev, Brian Moon, Kalle Sommer Nielsen, Edin Kadribasic Contra: Antony Dovgal, Derick Rethans, Jani Taskinen, Lokrain, Felipe Pena, Lukas Kahwe Smith, Marcus Boerger, David Soria Parra, Johannes Schlüter, Maciek Sokolewicz, Philip Olson, Ilia Alshanetsky, Daniel Brown, Jochem Maas, Hannes Magnusson, David Coallier Other voters Pro: Sebastian Deutsch, Ryusuke Sekiyama, Stefan Marr, Alexey Zakhlestin, Carl P. Corliss, Darius Jahandarie, Giedrius D, Eric Coleman, Max Antonov, Mike Ford, Larry Garfield, Sam Barrow, Taylor Luk, Hans Ahlin, Karoly Negyesi, Guilherme Blanco, Jonathan-Bond Caron Contra: Geoffrey Sneddon, Tomi Kaistila, David Zühlke -- Utilisant le logiciel de courrier révolutionnaire d'Opera : http://www.opera.com/mail/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php