[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string functions



Does (SUBSTRING string m n) mean character m THROUGH n or character m UP
TO n?  In Interlisp it means the former.  If you choose the former, it turns out to
be useful for various boundary cases for (SUBSTRING string m m-1) to deliver
the null string.  This allows 0 to mean the left end, i.e. (SUBSTRING string 1 0)
is null.  But it doesn't give any representation for the right end.

I think I favor the "up to" interpretation.  Given the choice, I would prefer to
keep 0-based indexing and pitch the negative indexing feature.

[*** begin flame ***]

Interlisp is full of little features where some argument to some function has six
different interpretations depending on whether it is a positive integer, negative
integer, NIL, T, atom, list, etc.  The problem with these "features" is that
	(1) they slow down all the primitives with extra checks all the time,
whether you use the features or not.
	(2) they reduce error-checking -- if your program thinks it's computed a
positive string index and it turns out to be negative, you get some unexpected
result instead of the error indication you wanted.
	(3) they make understanding programs (both humanly and mechanically)
harder because you have to do case analyses all the time.

Features of this kind look like creature comforts, but they wind up making life
harder in the long run.

[*** end flame ***]

"Opinions are like assholes: everybody has one."