Ford, Mike wrote on Friday, November 18, 2005 7:58 AM:
> On 17 November 2005 21:42, Rasmus Lerdorf wrote:
>
> > 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 [].
And most public code still uses hacks for register_globals, is insecure and
poorly written.
> So all of those who belived the "[] for string access is deprecated"
> line (or simply prefer the visual differentiation) and have 10s of
> thousands of lines of code with liberal use of $string{} are going to
> have to spend ages fixing that up?
Sounds like they got us good! No more listening to documentation for us...
> > Having two syntaxes for the same thing makes no sense,
And neither does arbitrarily removing one syntax; especially when that
syntax has been the recommended way of referencing characters in strings for
years.
> I don't buy this -- having two ways of doing certain things is one
> feature that makes PHP so great -- it increases the user base who
> find it easy to use, as they can pick the method that makes most
> sense to them. I love the {} syntax, so let me use it. You don't --
> fine, don't use it. (I won't convert to [] -- I'll go for
> substr(..,..,1) instead). Another example: I hate proliferating {}
> for control structures and use exclusively the if (): ... endif; form
> -- fine, let me use it; your preference may be otherwise, but that's
> fine too. In the end, each of us gets the PHP syntax we find easiest
> to use, without denying the other his preference. What's so wrong
> with that?
And with so much work to maintain backwards compatibility in the past, why
do we need this change now? While we're changing things, let's standardize
function parameter ordering.
> > 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.
Yup - if anything, let's remove [] as string access - then again, if it
ain't broke, why try to fix it?
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php