Re: Bug #13846 Updated: Patch: Use [ ] as shortcut for array()

From: Date: Sat, 27 Oct 2001 13:28:57 +0000
Subject: Re: Bug #13846 Updated: Patch: Use [ ] as shortcut for array()
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-69134@lists.php.net to get a copy of this message
Hello, I would say -1 on this, this is not readable and IMHO just a hack: $array = [['9', 34],[7],[1,'string']]; regrads, Derick On 27 Oct 2001 z4k4ri4@bigfoot.com wrote: > ID: 13846 > User updated by: z4k4ri4@bigfoot.com > Reported By: z4k4ri4@bigfoot.com > Status: Open > Bug Type: Feature/Change Request > Operating System: Any > PHP Version: 4.0.6 > New Comment: > > My browser mangling the patch see if these works > > --- php-4.0.6/Zend/zend_language_parser.y.zak Sun May 6 21:36:25 2001 > +++ php-4.0.6/Zend/zend_language_parser.y Sat Oct 27 11:20:06 2001 > @@ -481,6 +481,7 @@ > | '@' { zend_do_begin_silence(&$1 CLS_CC); } expr { zend_do_end_silence(&$1 > CLS_CC); $$ = $3; } > | scalar { $$ = $1; } > | T_ARRAY '(' array_pair_list ')' { $$ = $3; } > + | '[' array_pair_list ']' { $$ = $2; } > | '' encaps_list '' { > zend_do_shell_exec(&$$, &$2 CLS_CC); } > | T_PRINT expr { zend_do_print(&$$, &$2 CLS_CC); } > ; > @@ -533,6 +534,7 @@ > | '+' static_scalar { $$ = $1; } > | '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; > minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one); > $$ = $2; } > | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = > IS_CONSTANT_ARRAY; } > + | '[' static_array_pair_list ']' { $$ = $2; $$.u.constant.type = > IS_CONSTANT_ARRAY; } > ; > > > > > Previous Comments: > ------------------------------------------------------------------------ > > [2001-10-27 02:42:21] z4k4ri4@bigfoot.com > > In my script I use a lot of nested array() or array() as > parameter. So the array() things start to get in the way. > I assume many PHP programmer feels the same thing. > > We need a short version of array() construct, and I think > the [] is the best choice. It is used in python and ruby. > > After a little bit trying I finally could make a patch and > make it work on my server. > > I hope this patch will find its way to official php soon. > > WARNING: > I'm new in this whole bison & C thing so I maybe making some > silly mistake. > > --- php-4.0.6/Zend/zend_language_parser.y.zak Sun May 6 21:36:25 2001 > +++ php-4.0.6/Zend/zend_language_parser.y Sat Oct 27 11:20:06 2001 > @@ -481,6 +481,7 @@ > | > '@' { zend_do_begin_silence(&$1 CLS_CC); } expr { > zend_do_end_silence(&$1 CLS_CC); $$ = $3; } > | > scalar > { $$ = $1; } > | > T_ARRAY '(' array_pair_list ')' { $$ = $3; } > + > | > '[' array_pair_list ']' { $$ = $2; } > | > '' encaps_list '' { > zend_do_shell_exec(&$$, &$2 CLS_CC); } > | > T_PRINT expr { zend_do_print(&$$, &$2 CLS_CC); } > ; > @@ -533,6 +534,7 @@ > | > '+' static_scalar { $$ = $1; } > | > '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; > minus_one.value.lval = -1; mul_function(&$2.u.constant, > &$2.u.constant, &minus_one); $$ = $2; } > | > T_ARRAY '(' static_array_pair_list ')' { $$ = $3; > $$.u.constant.type = IS_CONSTANT_ARRAY; } > + > | > '[' static_array_pair_list ']' { $$ = $2; $$.u.constant.type > = IS_CONSTANT_ARRAY; } > ; > > > > > ------------------------------------------------------------------------ > > > > Edit this bug report at > http://bugs.php.net/?id=13846&edit=1 > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > Derick Rethans --------------------------------------------------------------------- PHP: Scripting the Web - www.php.net - derick@php.net SRM: Site Resource Manager - www.vl-srm.net ---------------------------------------------------------------------

« previous php.dev (#69134) next »