On Mon, Sep 07, 2009 at 10:43:43AM +0100, David Rush wrote:
> If I Remember Correctly, in R5, all continuations are explicitly
> single-argument except in one, very weird case which is within the
> CALL-WITH-VALUES form. And you can only capture that multi-arg
> continuation at that lexical point, it is unavailable in any of the
> called code. It's really quite grotesque.
I seem to recall having made a formal comment on an R6RS draft asking
that the matter of continuation equivalence be specified more explicitly
for the purpose of that arity restriction. Mike Sperber initially felt
it to be obvious that tail contexts / calls would *not* create a new
continuation but rather reuse the old one with its arity intact, but
later agreed that it could use some clarification.
A quick check of R5RS reveals, under section 3.5, that it cites as
a "formal definition of proper tail recursion" a block of text from
[8] containing the statement that "the continuation that is used
in the tail call has the same semantics as the continuation passed
to the procedure containing the call", which would mean that tail
calls preserve continuation arity, taking that to be part of the
continuation's semantics.
The extent to which this can be considered normative on R5RS
implementations may be debatable, but then the R5 does not seem to have
been written with IETF-grade rigor in mind.
[8] William Clinger. Proper Tail Recursion and Space Efficiency. In
/Proceedings of the 1998 ACM Conference on Programming Language
Design and Implementation/, June 1998.
--
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l)))))) (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k))))))) '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss