|
From: Ethan A M. <merritt@u.washington.edu> - 2005-07-04 18:38:48
|
On Monday 04 July 2005 01:10 am, you wrote:
> Secondly, and probably too late: word("s t r i n g", 1) fishes the
> first word ("s"), while substr("string",1,1) returns the second
> letter. I think both indices should start at the same value.
> Don't know how to solve this.
I don't know either. Perhaps I should just remove the substr()
function altogether. That would make a clear distinction between
the operation STRING[beg:end] (uses C-language indexing from 0)
and the function calls like word(STRING,N) (uses rexx or fortran
indexing starting from 1).
I don't think it's too late to change these; they've only been
in CVS for a short time. The question did come up in discussion,
but few opinions or answers were offered. I chose to go with logic
that if the function name came from a particular environment, rexx
in the case of word() and words(), it should maintain the indexing
convention that it was derived from.
But I agree that the substr(beg,end) indexing is confusing, and
contradicts the awk equivalent substr(beg,length) regardless
of whether beg starts at 0 or 1.
Petr: What are your thoughts? It was your suggestion to include
a subroutine form of the substring operator (and it was utterly
trivial to implement). But it may add more confusion than it is
worth.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|