Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5196 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87507 invoked by uid 1010); 5 Nov 2003 09:03:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87469 invoked from network); 5 Nov 2003 09:03:46 -0000 Received: from unknown (HELO amf.hotels-on-air.de) (217.194.75.126) by pb1.pair.com with SMTP; 5 Nov 2003 09:03:46 -0000 Received: from leetspeak.org ([10.10.30.112]) by amf.hotels-on-air.de (8.12.3/8.12.3/SuSE Linux 0.6) with ESMTP id hA593iO1000328 for ; Wed, 5 Nov 2003 10:03:45 +0100 Message-ID: <3FA8BCEF.7030300@leetspeak.org> Date: Wed, 05 Nov 2003 10:03:43 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030901 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net References: <20031104233306.34859.qmail@pb1.pair.com> <3FA8BC03.9050104@leetspeak.org> In-Reply-To: <3FA8BC03.9050104@leetspeak.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavis-milter (http://amavis.org/) Subject: Re: [PHP-DEV] Proposal: Array syntax From: cm@leetspeak.org (Michael Walter) > Very cool. > > How about supporting .. syntax, btw. as in [1..3] or ["a".."z"]? Might > no be the worth, just thinking out loud ;) "might not be worth it".. > > Christian Schneider wrote: > >> I propose to add an alternative (backward compatible) short array >> creation syntax: >> $a = [ 1, 2, 3 ]; and $a = [ 'a' => 42, 'b' => "foo" ]; >> >> It can also be used in function calls: >> img(['src' => "logo.gif", 'alt' => "Logo"]); >> >> Reason behind this change: Arrays are used a lot and should therefore >> have as little syntactic overhead as possible. And I think the short >> syntax is also easier to read and write. >> >> A patch for the parser is trivial and is attached for Zend2. >> >> Note: I checked the newsgroup archive but couldn't find a discussion >> about this. After not hearing back about my proposed enhancement to >> debug_backtrace() and the dangling comma for function call parameters >> being rejected I wonder if I'm using the right mailing list for this :-) >> >> - Chris >> >> >> ------------------------------------------------------------------------ >> >> Index: Zend/zend_language_parser.y >> =================================================================== >> RCS file: /repository/ZendEngine2/zend_language_parser.y,v >> retrieving revision 1.127 >> diff -u -r1.127 zend_language_parser.y >> --- Zend/zend_language_parser.y 19 Oct 2003 08:38:48 -0000 1.127 >> +++ Zend/zend_language_parser.y 4 Nov 2003 23:32:12 -0000 >> @@ -581,6 +581,7 @@ >> | '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { >> zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; } >> | scalar { $$ = $1; } >> | T_ARRAY '(' array_pair_list ')' { $$ = $3; } >> + | '[' array_pair_list ']' { $$ = $2; } >> | '`' encaps_list '`' { zend_do_shell_exec(&$$, &$2 >> TSRMLS_CC); } >> | T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); } >> ; >> >> >