This is an example from Waddell and Dybvig's paper "Extending the Scope of
Syntactic Abstraction", but I don't think it should work in R6RS Scheme:
Ypsilon 0.9.6-trunk/r503 Copyright (c) 2009 Y.Fujita, LittleWing Company
Limited.
> (library (M)
(export a b)
(import (rnrs))
(define-syntax a
(syntax-rules ()
[(_ e0 e1 ...) (e0 (quote c) e1 ... )]))
(define b (lambda () c))
(define c 3))
> (import (M))
> (let ()
(define-syntax f
(syntax-rules ()
[(_ (any id)) id]
[(_ (any id) value) (set! id value)]))
(let ([original (a f)])
(a f 4)
(list original (b))))
(3 4)
>
As you might find in the paper, (a f 4) expands to (f (quote c) 4) which
expands to (set! c 4). This is an attempt to change the variable inside the
(M) library, but from the outside.
An even simpler example (with explicitly exported bindings, instead of
implicit) is that e.g. (set! + -) works.
In R6RS, at the end of section 7.1, it says that both explicitly and
implicitly exported variables are immutable. So I think both examples in
this bug report should raise exceptions.
Original issue reported on code.google.com by weinh...@gmail.com on 1 Aug 2009 at 8:32
Original issue reported on code.google.com by
weinh...@gmail.com
on 1 Aug 2009 at 8:32