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 term one would only associate with strings.
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.
Thanks for that suggestion! On the one hand, negative indexing alone is simpler and less prone to typos, but it makes sense that using the slice operator would clarify the code.
SL
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 strings get it or nobody gets it.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
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 strings get it or nobody gets it.
I suppose one could still extend ArrayAccess and have their own negative indices support for arrays :)
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227