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

Abdulaziz Ghuloum aghuloum at cs.indiana.edu
Mon Mar 12 16:51:52 EDT 2007


On Mar 12, 2007, at 4:06 PM, Nathan Thern wrote:

>  Here is a modification to library L1 that gets around
> the above "loophole fix":
>
>   (library (L1)
>     (export y get-y set-y!)
>     (import (r6rs))
>     (define x #f)
>     (define y (car x))
>     (define z ((caddr x)))
>     (define get-y (lambda () y))
>     (define set-y! #f)
>     (set! x (call/cc (lambda (k) (list 0 k values))))
>     (set! set-y!
>       (lambda (v)
>         (call/cc (lambda (k) ((cadr x) (list v (cadr x) k)))))))

Note that this is an invalid library (cannot export mutable bindings).

The point was that Kent's program was exploiting the "invisible" set!
that comes from the letrec* implementation in order to change the value
of the "immutable" y.   The once-only restriction makes it an error to
modify the value of any library identifier by returning more than once
to the code that initialized the variable.

Aziz,,,



More information about the r6rs-discuss mailing list