Re: Negative string offset support
| From: | Robert Cummings | Date: | Fri, 29 Oct 2004 23:59:31 +0000 |
| Subject: | Re: Negative string offset support | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-13618@lists.php.net to get a copy of this message | ||
On Fri, 2004-10-29 at 19:31, Derick Rethans wrote:
> On Fri, 29 Oct 2004, Robert Cummings wrote:
>
> > On Fri, 2004-10-29 at 19:04, Derick Rethans wrote:
> >
> > > Yeah, [] is for arrays, {} for string indexes though I still think this
> > > should not be in, one can use substring for this. Something like a
> > > "negative string index" is IMO too much magic.
> >
> > Just as much magic as the negative start in substr() function. It would
> > be consistent with substr() precedent of negative indexes counting
> > backward from end of string.
>
> But substr() is a *function*, that's totally different from a language
> construct which should be a generic tool, not a specific one like Ilia
> is proposing here.
>
> > Also, everyone knows functions run slower than operators :)
> *cough*bullshit argument*cough*
Well for the amount of times you need to traverse backward in a string
it probably is a crap argument :) However it does indeed stand that
operators are processed faster than functions I would wager due to the
overhead of setting up parameters etc. Contrast is_null( $x ) versus $x
=== null, there's about 17% difference in speed. Similarly (0.0 + $x)
takes almost half the time of floatval( $x ).
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'