Re: Last Element Reference
The reason I suggested this change to Euphoria was not for the benefit of the
interpreter, or translator or compiler, but for the benefit of the coder and
maintainer. I am not troubled if this change causes my programs to run a few
milliseconds slower, so long as it can save time during coding, testing and
maintenace sessions - that is far more important to me.
My issue with negative indexes is that the reader must interpret '-1' as either
of two things, depending on context. In one situation it means negative one, and
in another it means the last element of a sequence. And please don't tell me that
-1 is ALWAYS the same as the "last element of a sequence".
a = b-1
a = b[-1]
are so similar visually but mean extremely different things.
a = b-1
a = b[$]
not only look different, they also are different - there is less mental
gymnastics to do.
And don't get hung up about a 'dollar' symbol - it could be any punctuation
character or special keyword - that is not the point. The point is that '$' does
not look like an arithmetic expression whereas '-1' does, and length(X) is not an
arithmetic expression either, its a property getter - it gets the 'length'
property of the sequence X.
Really, I was just hoping for some syntactic sugar to be able to quickly refer
to the end of the sequence in context. Sorry to cause so much angst.
--
Derek
|
Not Categorized, Please Help
|
|