rfc:objectarrayliterals
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:objectarrayliterals [2011/06/06 16:52] – add header sean | rfc:objectarrayliterals [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== RFC: First-Class Object and Array Literals ===== | ===== RFC: First-Class Object and Array Literals ===== | ||
- | * Version: 1.0 | + | * Version: 1.0.3 |
- | * Date: 2011-06-04 | + | * Date: 2011-06-04 |
* Author: Sean Coates < | * Author: Sean Coates < | ||
- | * Status: | + | * Status: |
==== Introduction ==== | ==== Introduction ==== | ||
Line 23: | Line 23: | ||
This proposal calls for first-class JSON-like object and array literals | This proposal calls for first-class JSON-like object and array literals | ||
(a.k.a. primitives, constructs) in PHP. | (a.k.a. primitives, constructs) in PHP. | ||
+ | |||
+ | This RFC supersedes the existing [[rfc: | ||
Line 41: | Line 43: | ||
Furthermore, | Furthermore, | ||
concerns a declaratative, | concerns a declaratative, | ||
+ | |||
+ | In JSON-proper, | ||
Point of discussion (see below): the key-value separator will be both PHP's | Point of discussion (see below): the key-value separator will be both PHP's | ||
Line 100: | Line 104: | ||
?> | ?> | ||
</ | </ | ||
+ | |||
+ | === Interaction with third-party services that speak JS-literals === | ||
+ | <code php> | ||
+ | <?php | ||
+ | // Here's how an ElasticSearch query currently looks in PHP: | ||
+ | |||
+ | $esQuery = new \StdClass; | ||
+ | $esQuery-> | ||
+ | $esQuery-> | ||
+ | $esQuery-> | ||
+ | $esQuery-> | ||
+ | |||
+ | // OR | ||
+ | |||
+ | $esQuery = (object)array( | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ) | ||
+ | ), | ||
+ | " | ||
+ | ); | ||
+ | |||
+ | // …and here's how it could look with the proposed syntax: | ||
+ | |||
+ | $esQuery = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | }; | ||
+ | |||
+ | /* | ||
+ | …and here's how I'd use curl to ensure that the query I'm issuing does in fact work with ElasticSearch: | ||
+ | |||
+ | $ curl http:// | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | }' | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | Even considering the '' | ||
+ | |||
+ | Note that this could have been written with the PHP definition of $esQuery in the proposed yet non-JSON compatible syntax (single quotes, for example), but it was written with double quotes because it is easier to pass off to curl. | ||
+ | |||
+ | Realistically, | ||
+ | |||
+ | The argument for right-hand-side assignments being allowed in the proposed syntax (such as in '' | ||
+ | |||
==== Benefits ==== | ==== Benefits ==== | ||
Line 148: | Line 208: | ||
* Performance concerns: encoding/ | * Performance concerns: encoding/ | ||
+ | ==== Patch ==== | ||
+ | * A partial (arrays only, colons only) [[http:// | ||
==== Discussions ==== | ==== Discussions ==== |
rfc/objectarrayliterals.1307379153.txt.gz · Last modified: 2017/09/22 13:28 (external edit)