[Nickle] substr("",0,0) ?
bart at cs.pdx.edu
Thu Apr 15 23:46:53 PDT 2004
Ok, you've just invoked
substr("", 0, 0)
or in general
substr(s, length(s), 0)
Nickle raises an illegal_argument exception because the
index is off the end.
Should it? I contend no, because it makes writing string
algorithms without special cases harder. But I can see the
argument. Should it matter if the index is "just" off the
end, or should you be able to extract 0 characters from
anyplace? I claim only just off the end, because that's the
only thing that makes any sense.
I guess my general intuition is that substring(s,m,n) should
be equivalent to
chars->string(head(tail(string->chars(s), length(s) - m), n))
If that is the case, then the natural meaning of the
functions suggests that I am right above.
Discussion? Or shall I call it a bug and fix it?
More information about the Nickle