Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74701 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40969 invoked from network); 3 Jun 2014 01:14:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jun 2014 01:14:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap2-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:44915] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/60-35712-4612D835 for ; Mon, 02 Jun 2014 21:14:13 -0400 Received: from [192.168.0.200] (unknown [90.203.28.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id D6C215A00F4 for ; Mon, 2 Jun 2014 21:14:08 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) In-Reply-To: <6E3D6B3F-1BD6-42A2-B59C-12B9D6D597ED@ajf.me> Date: Tue, 3 Jun 2014 02:14:05 +0100 Content-Transfer-Encoding: quoted-printable Message-ID: <3A13FF39-6AF4-4A0C-A503-897C39023768@ajf.me> References: <6E3D6B3F-1BD6-42A2-B59C-12B9D6D597ED@ajf.me> To: PHP internals X-Mailer: Apple Mail (2.1878.2) Subject: Re: [PHP-DEV] [RFC] Bare Name Array From: ajf@ajf.me (Andrea Faulds) On 1 Jun 2014, at 18:59, Andrea Faulds wrote: > I propose something similar for PHP. Where the key fits the profile of = IS_STRING, this RFC proposes that you can do this instead: >=20 > stringKey: 3, >=20 > Now it=92s only two characters, three including spaces, for the most = common case. It makes declaring arrays more convenient. Something I=92m considering adding to the RFC is support for quoted = names, such that you could do this: [=93stringKey=94: 3] Now, obviously, you can already do the same with the double arrow: [=93stringKey=94 =3D> 3] If that=92s the case, then what=92s the advantage? Well, it is even = closer to JSON and JavaScript now than before. By adding this, we=92d = have the bareName: and =93quoted name=94: syntaxes established in = arrays, and PHP developers would become familiar with them. = (Incidentally, Apple=92s new Swift language announced a few hours ago = uses [=93key=94: 3] for their hash map literals, though that=92s a bit = off-topic.) With that groundwork laid, a new RFC could be created proposing object = literals with identical syntax to JSON=92s objects, meaning you could = paste JSON into PHP and (unless it had dollar signs) it would be = perfectly valid PHP code and parse as you expect. It would support the = =93quoted key=94: and unquotedKey: formats, but none other, thus = aligning itself with JavaScript (and hence JSON, which uses =93quoted = key=94: exclusively). That would also be useful for creating disposable = objects. At present, the closest thing we have is immediately casting = arrays to objects, which is tedious, as well as acting weirdly in some = situations (integer keys in particular). The JSON stuff is not, however, part of this RFC. It=92s a separate RFC = and thing I would implement if a quoted name syntax was added to this = RFC and it passed. Also, I haven=92t yet added =93quoted key=94: syntax, = but I=92m considering it. -- Andrea Faulds http://ajf.me/