Re: [RFC] Bare Name Array

From: Date: Sun, 01 Jun 2014 19:56:47 +0000
Subject: Re: [RFC] Bare Name Array
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-74682@lists.php.net to get a copy of this message
On 1 Jun 2014, at 20:47, Rowan Collins <rowan.collins@gmail.com> wrote: > 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 = { myKey­: 'bar'­, 'myKe­y' => 'bob'­ } > => {:myKey=>"bar", "myKey"=>"bob”} To look at another popular language, it’s interesting Perl does the opposite to PHP: Perl: %hash = ( ‘key’, ‘value’ ); PHP: $hash = [ ‘key’ => ‘value’ ] Perl: %hash = ( key => ‘value’ ); PHP: $hash = [ key: ‘value’ ] While Perl’s => is for unquoted strings, PHP’s is for quoted strings, which is bizarre considering PHP is Perl-inspired. :) -- Andrea Faulds http://ajf.me/

« previous php.internals (#74682) next »