Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34758 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5527 invoked by uid 1010); 12 Jan 2008 00:54:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 5512 invoked from network); 12 Jan 2008 00:54:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2008 00:54:23 -0000 Authentication-Results: pb1.pair.com header.from=jeffg@activestate.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jeffg@activestate.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain activestate.com designates 209.17.146.130 as permitted sender) X-PHP-List-Original-Sender: jeffg@activestate.com X-Host-Fingerprint: 209.17.146.130 mx.activestate.com Linux 2.6 Received: from [209.17.146.130] ([209.17.146.130:48902] helo=mx.activestate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/E0-31723-EBF08874 for ; Fri, 11 Jan 2008 19:54:23 -0500 Received: from box5.activestate.com (box5.activestate.com [192.168.69.5]) by mx.activestate.com (Postfix) with ESMTP id 9226FE1327; Fri, 11 Jan 2008 16:54:22 -0800 (PST) Received: from opus.activestate.com (opus.activestate.com [192.168.69.200]) by box5.activestate.com (Postfix) with ESMTP id 82874D675; Fri, 11 Jan 2008 16:54:22 -0800 (PST) Message-ID: <47880FBE.6030508@activestate.com> Date: Fri, 11 Jan 2008 16:54:22 -0800 User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Gregory Beaver CC: internals@lists.php.net References: <1200066425.7376.9.camel@johannes.nop> <1200075842.16083.44.camel@johannes.nop> <1200077257.12559.7.camel@sbarrow-desktop> <4787BE7C.6080205@zend.com> <1200078780.12559.14.camel@sbarrow-desktop> <4787E50A.1000108@daylessday.org> <4787EF30.8000306@daylessday.org> <4787F9A4.2080700@activestate.com> <4788052B.6040101@chiaraquartet.net> In-Reply-To: <4788052B.6040101@chiaraquartet.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] SUMMARY: Array syntax From: jeffg@activestate.com (Jeff Griffiths) Gregory Beaver wrote: > Jeff Griffiths wrote: >> Antony Dovgal wrote: >> ... >>> Well, to me it matters whether the author is going to care of the >>> thing he's proposing or he's going to disappear right after it's >>> implemented. >> I didn't realize there was a section of the code flagged 'syntactic >> sugar' and only a few people maintained that part. it also seems >> ridiculous to debate a syntax *addition* such as this in terms of >> maintainability. Is it really is hard to maintain this patch to the >> parser? How hard is it to maintain this: >> >> $array[] = $foo; >> >> ...vs any other part of the codebase? > > Whoa, slow down cowboy! Ok! > Any change to the parser can have unexpected and even bizarre > ramifications in code. For instance, > > $a = $b([0]); > > would become perfectly legal syntax, and although it is pretty to those > of us who pine after ASCII art, its action is not as obvious as: > > $a = $b(array(0)); That's a matter of perspective, I parse JS code as easily as I do the above, because that's what I'm used to. I do think this type of 'terseness vs readability' debate about this syntax addition is perfectly valid and I think *users* of PHP like myself have a place in that debate. ... > Now, this may sound blunt, but the tone of your message suggests you > haven't worked much with parser generators or lexer generators in C. > They're one of the more quirky and finicky aspects of PHP internals, and > seemingly simple changes can result in ridiculously complex problems. You would be right about that, but I guess I had assumed the patch was solid seeing as no-one has argued against it based on its technical merits. I did qualify the above: "...vs any other part of the codebase?". If there is a technical reason why you shouldn't commit this patch ( it's buggy, etc ) then I am happy to concede the point to people who know much more about this than I do. Most of these threads on this proposal seem to be based on the usability / readability / ephemeral qualities it will bring to PHP, and not on whether it works or not. > I am used to arrays, and find them intuitive. I am a bit concerned > about code like this rearing its head: > > if (1) { > $a = [ > [ > ['a' => 1, 3], > ($b = 3), > ] > ]; > } else { > $a = [ > [ > ['b' => 1, 3] > ] > ]; > } I agree, that's a bit nasty. =) > "bracket hell" is not something I've associated with PHP much, and the > new syntax would definitely make it possible, but would also simplify > the amount of spurious stuff on the screen for me in my work if used well. > > So, I am +0.5 for [] syntax in principle. I have not examined the patch. Assuming the patch is fine ( which I have happily done so far ) it seems this proposal is at best controversial. JeffG