Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52598 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16702 invoked from network); 31 May 2011 22:02:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 May 2011 22:02:28 -0000 Authentication-Results: pb1.pair.com header.from=birken@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=birken@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: birken@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:33624] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/71-25701-27565ED4 for ; Tue, 31 May 2011 18:02:27 -0400 Received: by qwi4 with SMTP id 4so2659725qwi.29 for ; Tue, 31 May 2011 15:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=0Pd1t96fIxIrQ+cbHZXatV/tS/tJT7dmZmrsQ4so+EA=; b=gMHkxLlktZuMYpPgcuprFxdjPHyf2PscxZfrLseMgMD9SI4+rUoW72+5+f/ZAvMrYw RmwsdTpeiktBeVo6cKSs8FnPB4MSWWXTmGhHGJQIn0TU0VVoB34cvLbi7Vx5aV/B6c3q t8Zut8b88tPh1GekqWmVO7TUHjYk8PmaZYQmg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=r7yHKvtXdBFg6+nn1rO9cd9tXXhrz8Zm8sTEZXX6TAAAZA6fz1vNhtdiBaXriJ+qme jm8sKI6FuibS4kd/2+SEXpwmCvK6Nbwxeqk8gbFQEooSxJDX7IgEVGBM/e4erltznxPJ prE9RejnuVEZYZTXd5Rj7B+fLrWZPQ93/K/zE= MIME-Version: 1.0 Received: by 10.224.209.72 with SMTP id gf8mr4737569qab.362.1306879342812; Tue, 31 May 2011 15:02:22 -0700 (PDT) Received: by 10.224.60.69 with HTTP; Tue, 31 May 2011 15:02:22 -0700 (PDT) In-Reply-To: <4DE560D4.2010409@lerdorf.com> References: <4DE5368A.6050603@moonspot.net> <2BFFEAC1-395E-4101-9452-002E63DCFD91@seancoates.com> <4DE55AB7.9050206@lerdorf.com> <4DE55CDA.302@sugarcrm.com> <4DE560D4.2010409@lerdorf.com> Date: Tue, 31 May 2011 15:02:22 -0700 Message-ID: To: Rasmus Cc: PHP internals Content-Type: multipart/alternative; boundary=20cf300faeb5fe1e3304a4998e0c Subject: Re: [PHP-DEV] RFC: Short syntax for Arrays (redux) From: birken@gmail.com (Dan Birken) --20cf300faeb5fe1e3304a4998e0c Content-Type: text/plain; charset=ISO-8859-1 Yes it does :) I guess my point was it would be confusing if PHP supported JSON-like syntax, but json_decode(X) was different from eval(X). So if PHP isn't going to use JSON syntax (because it doesn't work for assoc arrays), then I don't think there is much benefit in using *almost* JSON syntax. It just seems simpler that: array(1, 2) equals [1, 2] array(1 => 2) equals [1 => 2] -Dan On Tue, May 31, 2011 at 2:42 PM, Rasmus wrote: > 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 > --20cf300faeb5fe1e3304a4998e0c--