Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-04 Thread Sharon Levy
Greetings. >> The main problem arises from the ambiguity for $array[-1] for arrays.>> But this is easily solvable: just introduce a slice operator. >> >> $array[:-1] and the ambiguity is gone. >That would return an array containing the last item as the sole member, >not the last item itsel

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-04 Thread Tjerk Anne Meesters
On Tue, Sep 4, 2012 at 6:31 PM, David Zülke wrote: > On 03.09.2012, at 09:37, Jannik Zschiesche wrote: > > > The main problem arises from the ambiguity for $array[-1] for arrays. > > But this is easily solvable: just introduce a slice operator. > > > > $array[:-1] and the ambiguity is gone. > > T

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-04 Thread Tjerk Meesters
On 4 Sep, 2012, at 3:59 AM, Stas Malyshev wrote: > Hi! > >> The terminology "negative indexing" seems to imply that the feature >> should work with arrays. To restrict it to just strings might involve >> creating a term one would only associate with strings. > > I do not see any way to change

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-04 Thread David Zülke
On 03.09.2012, at 09:37, Jannik Zschiesche wrote: > The main problem arises from the ambiguity for $array[-1] for arrays. > But this is easily solvable: just introduce a slice operator. > > $array[:-1] and the ambiguity is gone. That would return an array containing the last item as the sole me

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-03 Thread Stas Malyshev
Hi! > The terminology "negative indexing" seems to imply that the feature > should work with arrays. To restrict it to just strings might involve > creating a term one would only associate with strings. I do not see any way to change behavior of $array[-1] that would make sense. So either only st

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-03 Thread slevy1
>as I understood, a lot of people seem to have problems with this proposal, >since arrays and strings could (and maybe >should) behave the same. The terminology "negative indexing" seems to imply that the feature should work with arrays. To restrict it to just strings might involve creating a te

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-03 Thread Jannik Zschiesche
Am Sonntag, 2. September 2012 um 02:43 schrieb sle...@pipeline.com: > The idea was originally proposed by Marc Easen who created a patch and asked > for help with putting together an RFC. I have yet to see a formal proposal > but on the list Easen modified his idea so that it should apply to stri

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-02 Thread slevy1
>I see how this may work for strings and simple vectors, but what about this: > >$a = array(-1 => "foo", -2 => "bar"); echo $a[-1]; > >It should keep returning "foo", right? So then the question is - what >$array[-1] actually means? Context would be the deciding factor, i.e. perhaps restrict the

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-02 Thread Lester Caine
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 wa

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-02 Thread Stas Malyshev
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 implem

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-02 Thread Lester Caine
Stas Malyshev wrote: >The idea was originally proposed by Marc Easen who created a patch >and asked for help with putting together an RFC. I have yet to see a >formal proposal but on the list Easen modified his idea so that it >should apply to strings alone. With that in mind, would it really >

Re: [PHP-DEV] Re: Support negative indexes for arrays and strings

2012-09-01 Thread Stas Malyshev
Hi! > The idea was originally proposed by Marc Easen who created a patch > and asked for help with putting together an RFC. I have yet to see a > formal proposal but on the list Easen modified his idea so that it > should apply to strings alone. With that in mind, would it really > cause problem