Re: Questions, loose ends, misprints, etc. Andre van Tonder (01 Dec 2005 17:31 UTC)
Re: Questions, loose ends, misprints, etc. Per Bothner (01 Dec 2005 17:38 UTC)

Re: Questions, loose ends, misprints, etc. Per Bothner 01 Dec 2005 17:38 UTC

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
xxxxxx@bothner.com   http://per.bothner.com/