[r6rs-discuss] [Formal] Requirement to detect circular lists

AndrevanTonder andre at het.brown.edu
Tue Oct 3 19:00:53 EDT 2006


On Tue, 3 Oct 2006, Shiro Kawai wrote:

> Another thought hit me.  This 'plausible list' check on the argument
> can be done at any moment between the call of 'map' and alike and
> the return from it, right?  So an implementation can check the
> arguments upfront, before calling the given procedure, or it can
> check arguments while applying the procedure element by element.
> So the following code may return or raise an exception, when
> xs and/or ys are not plausible list of length N.
>
> (call/cc
>   (lambda (k)
>     (for-each (lambda (x y) (if (negaive? x) (k y))) xs ys)))

I think the arguments must be checked up front for all the higher order
procedures.  This seems to be required by the "must" in sentences to the 
effect:

"an exception must be raised if list is not a plausible list"

in the notes to length and map, which I assume must apply to all these 
procedures.  So an exception has to be raised in this case, right?

If the specification requires the lists to be checked up front, though, that 
reopens some efficiency issues, since now a double traversal is 
not optional, but required.  Imagine the lists having a million elements, of 
which the first element is negative.  The percentage difference in performance 
could easily be 100,000,000% !

Andre



More information about the r6rs-discuss mailing list