[dev] Fwd: Re: [PHP-DEV] dropping curly braces

Chuck Hagenbuch chuck at horde.org
Thu Nov 17 13:46:07 PST 2005


FYI. Someone want to start grepping?

----- Forwarded message from rasmus at lerdorf.com -----
     Date: Thu, 17 Nov 2005 13:42:27 -0800
     From: Rasmus Lerdorf <rasmus at lerdorf.com>
Reply-To: Rasmus Lerdorf <rasmus at lerdorf.com>
  Subject: Re: [PHP-DEV] dropping curly braces
       To: Andreas Korthaus <akorthaus at web.de>
       Cc: internals at lists.php.net, Ilia Alshanetsky <ilia at prohost.org>

Andreas Korthaus wrote:

> Can someone tell me the reason for this decision?

Very few people converted to using {} so the argument about reading old
code doesn't really hold.  If you go and grep through all the public
code out there, pretty much none of it uses {} for character offsets.
And internally there is absolutely no difference between {} and [].
Having two syntaxes for the same thing makes no sense, and getting rid
of [] would break all sorts of stuff.  The original reason for the {}
was a technical one to simplify the parser, but the landscape has
changed and that reason no longer exists.

As far a code readability and obviousness goes, I doubt anybody would
guess their way to the $str{5} syntax.  If you were new to PHP and you
were going to try to guess how you would get a character offset in a
string, what would your first guess be?  Most non-PHP people I have
asked have answered [].  Removing the obvious syntax just doesn't make
any sense.  The other place {} is used outside of control blocks is in
quoted strings where "{$foo{1}}" is much uglier than "{$foo[1]}".

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


----- End forwarded message -----


-chuck

-- 
"But she goes not abroad in search of monsters to destroy." - John 
Quincy Adams


More information about the dev mailing list