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

An alternative to ACCEPTS?



[This is not part of the multiple values compromise.]

As an alternative to providing ACCEPTS?, maybe we should simply
provide a way of generating truncating continuations.  Suppose we
provided a procedure like CALL-WITH-CURRENT-CONTINUATION, except that
if the escape procedure generated by CALL-WITH-CURRENT-CONTINUATION
accepts exactly n arguments, the new procedure generates an escape
procedure which will accept n or more arguments, and ignore the extra
ones.  The advantage of this approach is that implementations are only
required to be able to compute the arity of escape procedures, not all
procedures.  Here is an example of its use:

    (define (quotient-and-maybe-remainder n1 n2)
       (call-with-truncating-continuation
           (lambda (k)
              (let* ((q (quotient n1 n2))
                     (r (- n1 (* q n2))))
                 (k q r)))))

(quotient-and-maybe-remainder 1 1) => 1

John