Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52589 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3851 invoked from network); 31 May 2011 21:42:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 May 2011 21:42:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.210.42 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:45908] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/BE-25701-9D065ED4 for ; Tue, 31 May 2011 17:42:50 -0400 Received: by pzk37 with SMTP id 37so2387737pzk.29 for ; Tue, 31 May 2011 14:42:46 -0700 (PDT) Received: by 10.142.125.8 with SMTP id x8mr1198320wfc.14.1306878166136; Tue, 31 May 2011 14:42:46 -0700 (PDT) Received: from [192.168.200.149] (c-76-126-236-132.hsd1.ca.comcast.net [76.126.236.132]) by mx.google.com with ESMTPS id k20sm242144wfh.8.2011.05.31.14.42.45 (version=SSLv3 cipher=OTHER); Tue, 31 May 2011 14:42:45 -0700 (PDT) Message-ID: <4DE560D4.2010409@lerdorf.com> Date: Tue, 31 May 2011 14:42:44 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Dan Birken CC: PHP internals References: <4DE5368A.6050603@moonspot.net> <2BFFEAC1-395E-4101-9452-002E63DCFD91@seancoates.com> <4DE55AB7.9050206@lerdorf.com> <4DE55CDA.302@sugarcrm.com> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Short syntax for Arrays (redux) From: rasmus@lerdorf.com (Rasmus) On 05/31/2011 02:34 PM, Dan Birken wrote: > It is worth noting that point you bring up is one that is present in PHP > currently: > > php > print_r(json_decode(json_encode(array('a' => 'b')))); > stdClass Object > ( > [a] => b > ) > > php > print_r(json_decode(json_encode(array('a', 'b')))); > Array > ( > [0] => a > [1] => b > ) Sure, but that makes makes perfect sense, does it not? Javascript does not have associative arrays. So any non-scalar array has to be mapped to a Javascript object in order to be represented. When we bring it back we map a Javascript object to a PHP object, however, there is an optional argument on json_decode() to change that to an associative array if desired. The point we are making is that this exact inability of the json notation to distinguish an associative array from an object makes it a problematic choice for a native syntax in PHP. -Rasmus