Hi again,
Andrea Faulds wrote:
At present a negative offset is interpreted as being the maximum string
length plus that offset, so $str[-1] is equivalent to $str[(2**64 - 1) -
1]. In practice, this means you will get an empty string and an
"Uninitialized string offset:" E_NOTICE. It's not useful except for
extremely large strings and so I suspect that behaviour comes from an
implementation detail (naïve signed-to-unsigned integer conversion).
What you're proposing is to have the negative offset be interpreted as
an offset from the end of the string, as the built-in functions do. This
is more useful, but it's a change of behaviour from the present one, and
thus a backwards-compatibility break, even if it's unlikely to affect
real-world code. So, you might wish to mention that.
Er, ignore what I just said. Negative string offsets are actually
special-cased and always produce an "Unitialized string offset" or
"Invalid string offset" notice. So our current behaviour is in fact
completely useless, not just mostly. :)
Sorry about that.
--
Andrea Faulds
https://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php