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

From: Abdulaziz Ghuloum <aghuloum>
Date: Mon Mar 12 16:52:33 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,,,
Received on Mon Mar 12 2007 - 16:51:52 UTC

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