Robert Sanderson writes:
> >Referring back to the original email:
> > > substring="-2:0" -- the last two characters // not possible currently
> > > substring="0:0" -- the last character
> >
> >Shouldn't substring="-2:0" be the last *three* characters, as
> >substring="-1:0" would be the last two?
>
> Yes.
>
> The fault is mine -- I'm a python programmer at heart, and the python
> syntax is very similar:
>
> string[start:end]
> 0 based, where negatives count backwards, end is *not* inclusive and
> start or end omitted means start or end of the string.
>
> So in python, "string"[-2:] == "ng"
>
> The other issue with my poor examples was that I was also considering
> not having 0 at all, and the last character of the string would then be
> -1, as the first character of the string would be 1, but then thought
> that changing as little of the current proposal as needed would be
> better.
Urrgh. Yikes.
> >The proposed substring function is really many functions in
> >disguise. I reckon it is at least five distinct functions:
>
> At least. But we don't really want 5 or more relation modifiers that
> each cover a small part of the functionality of substrings, do we?
I sort of agree with Ashley that this is overloaded; but I also agree
with Rob that breaking it into five is not the solution. I think that
going to a 1-based index is a mistake, and that the consequent benefit
of getting to use 0 to mean "the end" is too small to be worth the
cost. I think the proposal as it stands is just about right.
_/|_ ___________________________________________________________________
/o ) \/ Mike Taylor <[log in to unmask]> http://www.miketaylor.org.uk
)_v__/\ "If all our misfortunes were laid in one common heap, whence
everyone must take an equal portion, most people would be content
to take their own and depart" -- Socrates.
|