Re: dropping curly braces
| From: | Ron Korving | Date: | Fri, 18 Nov 2005 14:16:56 +0000 |
| Subject: | Re: dropping curly braces | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20150@lists.php.net to get a copy of this message | ||
I hear a lot of opinions here on the curly braces issue, and while I don't
use them, they're not in the way. I'd say let's keep them in.
> > 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?
>
> Well, it wouldn't be [] because I'd guess that's for array access as in
> other
> languages. I probably wouldn't guess at all, but look it up, and be very
> happy to find it was {}. I remember being very, very surprised to find []
> doing double duty, and glad that {} existed as an alternative.
You obviously have no C(++) experience. People with the C-background
consider strings to be arrays of characters, and therefor it makes perfect
sense to use [], just like it makes sense to use [] for strings in C.
I don't see a problem with {} however, and see no reason why it should be
removed. I don't find it disturbing when I have to read someone's code
containing {}, so why remove it and make a lot of people angry? I don't see
the improvement except that certain warm and fuzzy feeling...
Ron