Re: Re: Support negative indexes for arrays and strings

From: Date: Sun, 02 Sep 2012 09:06:23 +0000
Subject: Re: Re: Support negative indexes for arrays and strings
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-62663@lists.php.net to get a copy of this message
Hi! > 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. > 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'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. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#62663) next »