no continuations
Ashley Yakeley
ashley at semantic.org
Fri Jan 9 15:48:13 EST 2004
In article <1073668638.3ffee21e290c4 at webmail.emba.uvm.edu>,
dvanhorn at emba.uvm.edu wrote:
> In this post to c.l.scheme, Dorai Sitaram writes:
>
> letrec with set! is certainly different from letrec with Y,
> and you don't need call/cc to distinguish the two.
>
> (define *keep-track* '())
>
> (letrec ((fact (lambda (n)
> (set! *keep-track* (cons fact *keep-track*))
> (if (= n 0) 1
> (* n (fact (- n 1)))))))
> (fact 8))
>
> and then do
>
> (eq? (car *keep-track*) (cadr *keep-track*))
>
> If letrec is set!-based (as in Scheme), the
> result is #t. If it is Y-based, the result is #f. Why
> this is should be obvious if you mentally (or with
> pencil) trace what Y does.
Does Haskell mfix count as Y? My implementation is mfix-based, and the
above code returns 40320 #t. Try it yourself at <http://hscheme.sourceforge.net/interpret.php>
if you don't believe me.
I'd be very interested to know if my implementation of Scheme varies
from R5RS due to this issue.
--
Ashley Yakeley, Seattle WA
More information about the Haskell-Cafe
mailing list