RE: subsequence and item-at

> concerning the subsequence function I would suggest to 
> specify it similary to substring. This would be consistent 
> and answer such questions like "what if $startingLoc is negative" etc.

I agree that this is worth looking at. Generally the style for newer
functions has been to report errors for "unreasonable" arguments rather than
to fallback, but this needs to be balanced against the need for consistency.
> 
> Additionally, item-at($seq, $pos) should IMO return the same 
> as subsequence($seq, $pos, 1) i.e. instead of raising an 
> error "Invalid position" this function would return the empty 
> sequence if $pos is out of bounds. This poses the question if 
> item-at is necessary at all, since subsequence($seq, $pos, 1) 
> would do the task.
> 

The advantage of item-at() over subsequence() and $seq[$pos] is mainly for
people interested in static type checking: item-at() is the only one of
these that guarantees statically to return exactly one item in the result.

Michael Kay

Received on Monday, 20 January 2003 10:50:58 UTC