Re: Re: Support negative indexes for arrays and strings

From: Date: Sun, 02 Sep 2012 09:27:46 +0000
Subject: Re: Re: Support negative indexes for arrays and strings
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-62665@lists.php.net to get a copy of this message
Stas Malyshev wrote:
Stanislav I though that the discussion on adding this type of functionality to
strings was already a done deal? Despite the obvious problems it introduces. I'm not sure what you mean by "done deal". There was this RFC: https://wiki.php.net/rfc/strncmpnegativelen but that wasn't implemented due to some objections. There's also a pull about negative strings offset but no RFC and no vote was ever held on it.
And obviously no 'we are not going to do this' ... It does get difficult at time to work out what IS still under discussion. I think I'm getting confused with the extra indicies bits that were added at some point? Accessing array stored string content by character index ... god this is getting complicated!
I've already pointed out why there is no way that this can be discussed in connection with 'collection arrays' and so there does need to be a clean break between the two for ANY discussion. I believe that PHP is the only language that allows us to use -ve indices ( i.e. keys ) in arrays? That was one of the nice Depending what you mean by "arrays". I'm sure any language that has maps indexed by value would not exclude values equaling to negative numbers. E.g. in python:
a = {} a[-2] = 1 a
{-2: 1}
I wonder if that was added because of the PHP methods?
I'm not sure we need or can do anything else for arrays. We maybe could for strings, technically, though I'm not currently convinced that having substr() we really need to. But if the vote goes other way, for strings I think it may be OK, if we figure out what to do with out-of-the-string offsets.
'Add an exception' ;) -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

« previous php.internals (#62665) next »