[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions, loose ends, misprints, etc.



Andre van Tonder wrote:
 Per Bothner wrote:
> (library "foo-counter" "scheme://r6rs"
 >    (export get-foo incr-foo)
 >    (define foo 1)
 >    (define-syntax get-foo
 >      (syntax-rules ()
 >        ((get-foo)
 >         foo)))
 >    (define-syntax incr-foo
 >      (syntax-rules ()
 >        ((incr-foo)
 >         (set! foo (+ foo 1))))))
> In the example, get-foo and incr-foo are exported, but foo itself is
 > not.  The compiler can prove that foo is never modified expect by
> using incr-foo. This statement does not seem correct to me. This fact would only become apparent after use of a macro in the client code. The line (set! foo ....) is compiled at the use site during compilation of the client, not at the macro definition site.

But foo is renamed - thanks to macro hygiene.  Even though incr-foo
expands to (set! foo ...) at the use-site, the name foo is not lexically
visible, and is unrelated to any other name that "looks like" foo.
--
	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/