On Wed, 2009-05-06 at 07:25 +0200, Michele Simionato wrote:
> On Wed, May 6, 2009 at 7:02 AM, Michele Simionato
> <[email protected]> wrote:
> > Can you see how confusing is this?
> 
> BTW, here is another behaviour which caused me a lot of
> confusion. Consider this library
> 
> (library (experimental visit)
> (export a m)
> (import (rnrs))
> (define-syntax m
>   (begin
>     (display "visiting\n")
>     (lambda (x) #f)))
> (define a 42)
> )
> 
> and this script
> 
> $ cat x.ss
> (import (rnrs) (experimental visit))
> ;(m) ;; calling this macro "should" have no effect
> (display a)
> 
> Notice that the call to the macro is commented. Superficially,
> one would expect the code to behaves in the same mode
> if the macro is called or not (this is a do-nothing macro, after all!).

What are you talking about?!  The macro does something: it expands to #F
like it's supposed to.  It has to expand like you requested!  In order
to expand, the transformer has to exist, which means visiting has to be
done.

> Instead things are different when separate compilation is used.
> 
> $ ikarus --compile-dependencies x.ss
> visiting
> Serializing "/home/micheles/gcode/scheme/experimental/visit.sls.ikarus-fasl" 
> ...
> 
> With the macro commented one gets:
> 
> $ ikarus --r6rs-script x.ss
> 42
> 
> With the macro NOT commented one gets
> 
> $ ikarus --r6rs-script x.ss
> visiting
> 42
> 
> Now I understand the reason: the library is visited only when the
> macro is called (here the library is instantiated for sure, since I access
> the variable a). However, from the point of view of the programmer
> not knowing the internals of Ikarus, he sees a do-nothing operation
> which has an observable effect.

It's not do-nothing -- the script has to be compiled, which means the
macro use has to be expanded, which means visiting the exporter of the
transformer is required.

I think you're suffering from an understandable confusion of terms and
concepts.  In the R6RS document, "visiting" means the syntax definitions
are evaluated, and "instantiating" means the variable definitions are
evaluated.  These two things can happen independently.  However, we've
often been using "instantiate" to mean *either or both* evaluating
syntax and/or variable definitions, and using "invoke" to mean what R6RS
means by "instantiate".

-- 
: Derick
----------------------------------------------------------------

Reply via email to