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

Re: Comments on SRFI-1.



>>>>> On Mon, 4 Jan 1999 10:24:52 -0600 (CST), Shriram Krishnamurthi <shriram@xxxxxxxxxxx> said:

> Harvey J. Stein wrote:
>> Maybe better than list-length>= would be (list-ref-with-default l n
>> default-value, which returns default-vaule if (>= (length l) n).

> That doesn't mean the programmer will know what value to provide --
> indeed, this increases the possibility of error.  To be safe, in the
> worst case, he would have to scan the entire list to make sure the
> default-value isn't in it (remember, Scheme doesn't have a
> generative struct mechanism either), or tack a token onto every
> value already in the list.  Clearly, neither of these is viable.

(let* ((sentinel (cons 0 0))
       (value (list-ref-with-default l n sentinal)))
    (if (eq? value sentinel)
       ...not found...
       ...found...))

But I agree that continuations are cleaner.

../Dave