Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27796 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41917 invoked by uid 1010); 5 Feb 2007 10:20:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 41902 invoked from network); 5 Feb 2007 10:20:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2007 10:20:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.226.6.51 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.226.6.51 darkcity.gna.ch Linux 2.5 (sometimes 2.4) (4) Received: from [195.226.6.51] ([195.226.6.51:40288] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/D0-18726-7F407C54 for ; Mon, 05 Feb 2007 05:20:40 -0500 Received: from localhost (localhost [127.0.0.1]) by darkcity.gna.ch (Postfix) with ESMTP id 51AFDB9FB1; Mon, 5 Feb 2007 11:20:37 +0100 (CET) Received: from unknown by localhost (amavisd-new, unix socket) id client-XXshJv5Z; Mon, 5 Feb 2007 11:20:34 +0100 (CET) Received: from [192.168.1.42] (217-162-171-242.dclient.hispeed.ch [217.162.171.242]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTP id 63E23B9FA1; Mon, 5 Feb 2007 11:20:34 +0100 (CET) Message-ID: <45C704F0.4040703@cschneid.com> Date: Mon, 05 Feb 2007 11:20:32 +0100 User-Agent: Thunderbird 1.5.0.9 (Macintosh/20061207) MIME-Version: 1.0 To: ceo@l-i-e.com CC: internals@lists.php.net References: <011701c7482d$a39f6910$6500a8c0@zend.2k> <45C5EC63.7030605@cschneid.com> <1902.67.184.122.32.1170651145.squirrel@www.l-i-e.com> In-Reply-To: <1902.67.184.122.32.1170651145.squirrel@www.l-i-e.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at gna.ch Subject: Re: [PHP-DEV] Re: Syntactic improvement to array From: cschneid@cschneid.com (Christian Schneider) Richard Lynch wrote: > So now we have an invisible operator with a magical symbol '[' which > *sometimes* means create an array, but *sometimes* means to > de-construct an array into individual variables? The distinction you are making is from an implementation point of view. From a language users point of view you're just dealing with arrays. Some people consider the distinction of the two a feature, some consider it a bug. > That's just disgusting, imho. To me it makes array usage more orthogonal and hence simpler, but that's obviously a matter of taste. What's also beautiful about [] IMHO is the symmetry of the syntax, list() and array() are asymmetrical which I always found inferior. >> - func('foo' => $foo, 'bar' => $bar, ...) equivalent to >> func(array('foo' => $foo, 'bar' => $bar, ...), see >> http://cschneid.com/php/ for more info > > Again, saving 5 characters just to confuse the hell out of idiots like > me does not seem like a "win" for PHP. :-v It is NOT about saving characters. If is about less clutter. The more important saving for us is the removal of an additional pair of parens which look like line-noise when nested. Funnily enough I forgot the closing parens of array() in my example above :-) I agree that our function call syntax is somewhat magical as it automatically starts and stops the array-composition when encountering key => value pairs so I wasn't really expecting much love for this from the list. But one can dream :-) Anyway, back to the main topic: I'm surprised how much hate a syntactic change like the one proposed by Andi still provokes nowadays when well established languages like C, C++, Javascript, Python and Ruby seem to successfully use [] or {} to construct arrays. My personal summary of this thread is: We won't have syntactic sugar for common things like arrays, named parameter emulation and the like ever because it will be killed by the "we already have a way of doing this" and the "you cannot look it up" argument. Shame, that would be the tiny language development I'd personally benefit from. Regards, - Chris