Comments on SRFI-1.
Harvey J. Stein
(04 Jan 1999 10:35 UTC)
|
Comments on SRFI-1.
Shriram Krishnamurthi
(04 Jan 1999 15:41 UTC)
|
Comments on SRFI-1.
Shriram Krishnamurthi
(04 Jan 1999 15:56 UTC)
|
Re: Comments on SRFI-1.
hjstein@xxxxxx
(04 Jan 1999 16:05 UTC)
|
Re: Comments on SRFI-1. Shriram Krishnamurthi (04 Jan 1999 16:24 UTC)
|
Re: Comments on SRFI-1.
Dave Mason
(04 Jan 1999 16:30 UTC)
|
Re: Comments on SRFI-1. Shriram Krishnamurthi 04 Jan 1999 16:24 UTC
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. The way to avoid this sort of misery is to pass in "continuations" (ie, procedures that are invoked in tail position). Your procedure would take two continuations, for success (if the list is long enough, feed the remainder to this) and failure (the list isn't long enough; maybe an argument saying how long it actually was?). This scans the list once, avoids default-values, doesn't leak computation, and is elegant in the Schemish way: it uses two powerful things that Scheme already has (closures and tail-calls) to work around what it doesn't have (exceptions). 'shriram PS: Since I'm on srfi-1, please remove my name from the distribution. I see you and Olin are on it, too.