[r6rs-discuss] [Formal] eliminate library export immutability loophole

From: AndrevanTonder <andre>
Date: Mon Mar 19 11:43:00 2007

On Sun, 11 Mar 2007, R. Kent Dybvig wrote:

> Okay, here's one example:
>
> (library (L1)
> (export y get-y set-y!)
> (import (r6rs))
> (define x (call/cc (lambda (k) (list 0 k values))))
> (define y (car x))
> (define z ((caddr x)))
> (define get-y (lambda () y))
> (define set-y!
> (lambda (v)
> (call/cc (lambda (k) ((cadr x) (list v (cadr x) k)))))))
>
> By my reading of the current library description, the program:
>
> (import (r6rs) (L1))
> (write (list y (get-y))) (newline)
> (set-y! 3)
> (write (list y (get-y))) (newline)

Doesn't the example violate the LETREC* restriction, though?

   One restriction on letrec* is very important: it must be possible to evaluate
   each <init> without assigning or referring to the value the corresponding
   <variable> or the <variable> of any of the bindings that follow it in
   <bindings>.

In particular, the second time the RHS of the (define x ....) binding is
evaluated, you are actually referring (via the (cadr x) in set-y!) to the
value of x itself. So the example may already be illegal.

Andre
Received on Mon Mar 19 2007 - 11:42:25 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC