no continuations

Ashley Yakeley ashley at
Fri Jan 9 22:07:37 EST 2004

In article <20040110040353.37C17AB8D at>,
 oleg at wrote:

> >   (define circular (letrec ((c (cons 'x c))) c))
> I'm afraid that is not a R5RS compliant code.

Indeed not, it merely demonstrates fixed-point behaviour. Nevertheless, 
allowing this as an extension does not make my implementation 
non-compliant. See section 1.3.2 on this point.

> > Do you have an example of use of Y for letrec where a program would 
> > violate R5RS?
> m
> The difference between the Y and set! approaches to letrec *is*
> observable.

I don't believe you. My implementation uses Haskell's "mfix", which 
looks like a Y to me. I certainly don't use anything like "set!". But my 
implementation passes Dorai Sitaram's test:

  (define *keep-track* '())

  (letrec ((fact (lambda (n) 
                 (set! *keep-track* (cons fact *keep-track*))
                 (if (= n 0) 1
                     (* n (fact (- n 1)))))))
  (fact 8))
  (eq? (car *keep-track*) (cadr *keep-track*))

My implementation returns 


...which is apparently correct behaviour for R5RS. Indeed I get exactly 
the same result in mzscheme and guile. Again, I encourage you to try for 
yourself at <> (though it's a bit slow).

Ashley Yakeley, Seattle WA

More information about the Haskell-Cafe mailing list