2009/9/8 Jed Davis <[email protected]>:
> 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.
...
> 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.
That would be the one :) The continuation of the producer thunk of the
CALL-WITH-VALUES form has (potentially) non-unitary arity. Mind you,
I'm not entirely sure that the exact arity of that continuation can be
statically determined (in fact I am pretty sure it cannot be), so it's
all pretty horrible really. Consider:
(LET ((evil-consumer (if free-boolean-var? (LAMBDA (v1 v2) ...)
(LAMBDA (v1 v2 v3) ...))))
(CALL-WITH-VALUES
(CALL-WITH-CURRENT-CONTINUATION
(LAMBDA (k)
(LAMBDA () (k 1 2))))
evil-consumer
))
And when I was a larval Scheme programmer, I actually used this
paradigm to write an extensible looping construct. I made it
work...eventually. I also learned my lesson about CALL-WITH-VALUES.
Scheme is really better off without it. If you find explicit CPS to be
too painful to look at just aggregate/deconstruct the values yourself.
Your code will be much cleaner and you can enjoy the satisfaction of
know that you have done the right thing :)
david rush
--
GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss