Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74691 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80881 invoked from network); 2 Jun 2014 06:39:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2014 06:39:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.179 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 74.125.82.179 mail-we0-f179.google.com Received: from [74.125.82.179] ([74.125.82.179:53284] helo=mail-we0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/6A-15017-C0C1C835 for ; Mon, 02 Jun 2014 02:39:08 -0400 Received: by mail-we0-f179.google.com with SMTP id q59so4513762wes.24 for ; Sun, 01 Jun 2014 23:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=IuJxTjnrKLQGiGSyFLrvdm0qjOQmSD3NKQWnGe+4ZFU=; b=W0yqgao6JGgVDiwdk13BgErJOgazyRL35LwmIZexZE3vTV9B31lc6BTYak2Sj3u3Kv LalXB2lPFhyhNGjOUd33QE0oU1bp3aMpx19bmotj4mWCbDS20jPW4cjM4vJnXd3LSGrq q2fQVIUoo77rGOwjIbGJpNlElQbNuNqM0S3kEk3Wd0Oaaq8bxFKGTAx5gob4fu+nT4Ms J3b+Hfmsa1LkcYnT5J4Fua3rLoTAXdwXYtiYY+Aa/5kT2dZ04qyj8ystl/7aMNyh8CL3 fpiHyyCvkOFASry0RAZt0445xSgu3WhxwYyeOBVZjAG/h/DqvZXkCJl18ZIMegl45VeC 5ZpQ== X-Received: by 10.180.185.244 with SMTP id ff20mr19475118wic.42.1401691144434; Sun, 01 Jun 2014 23:39:04 -0700 (PDT) Received: from nikita-optiplex-9020 (bba428041.alshamil.net.ae. [83.110.235.51]) by mx.google.com with ESMTPSA id d6sm32898824wjb.4.2014.06.01.23.38.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 01 Jun 2014 23:39:03 -0700 (PDT) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <6E3D6B3F-1BD6-42A2-B59C-12B9D6D597ED@ajf.me> <538B8364.6000903@gmail.com> Date: Mon, 02 Jun 2014 10:38:55 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] [RFC] Bare Name Array From: inefedor@gmail.com ("Nikita Nefedov") On Sun, 01 Jun 2014 23:56:03 +0400, Adam Harvey wrote:= > On 1 June 2014 12:47, Rowan Collins wrote: >> On 01/06/2014 18:59, Andrea Faulds wrote: >>> >>> The first is a less cumbersome syntax for arrays. At present, string= = >>> keys >>> in arrays are declared like this: >>> >>> =E2=80=9CstringKey=E2=80=9D =3D> 3, >>> >>> [...] Where the key fits the profile of IS_STRING, this RFC proposes= = >>> that >>> you can do this instead: >>> >>> stringKey: 3, >> >> >> Interestingly, I notice Ruby's hash syntax has two variants very = >> similar to >> this [http://www.ruby-doc.org/core-2.1.2/Hash.html]. >> >> However, in that case, the unquoted version represents a use of Ruby'= s >> special "Symbol" type, which is actually a different fundamental type= = >> from a >> String. So the following actually defines a 2-element hash, with one = = >> Symbol >> key and one String key: >> >> foo =3D { myKey: 'bar', 'myKey' =3D> 'bob' } >> =3D> {:myKey=3D>"bar", "myKey"=3D>"bob"} > > You've mostly pre-empted the question I wanted to ask. :) > > Andrea, did you consider implementing something more like Ruby's > symbols, rather than a variation on the existing array literal syntax?= > I feel like that might solve any potential ambiguities in terms of > constant resolution (as mentioned in another subthread), wouldn't > require a separate [foo: bar] variant on the existing syntax, and may > be useful in other contexts too (such as array dereferencing). > > As for the array dereferencing syntax: it should probably be an RFC > and patch on its own. To be honest, my initial reaction is negative =E2= =80=94 > I think the proposed syntax blurs the lines between arrays and objects= > (I know it's a different digraph, but it's going to look really > similar when scanning code), and I'm not yet sold on it being > particularly useful. Hi, Actually Ruby's symbol is like PHP's string. It's immutable and it's = interned. Unlike Ruby's strings which are mutable. So the question is in= = the syntax only...