On Wed, May 6, 2009 at 9:11 AM, Derick Eddington
<derick.edding...@gmail.com> wrote:
>> >  E.g., for the below, do you think (macro-helper) should always be
>> > instantiated?
>>
>> Yes.
>>
>> > (library (foo)
>> >  (export x)
>> >  (import (rnrs) (macro-helper))
>> >  (define-syntax s
>> >    (lambda (stx) (helper stx)))
>> >  (define x (s)))
>> >
>> > When (foo) is separately compiled, (macro-helper) needs to be
>> > instantiated for phase 1, but when pre-compiled (foo) is separately
>> > used, (macro-helper) does not need to be instantiated.  Since it doesn't
>> > need to be instantiated, why should it be?
>>
>> Because the module macro-helper could have side-effects, such
>> as registering objects at compile time (I am still thinking of the
>> use cases in the Compilable and Composable Macros paper)
>
> But I was talking about run-time!  A library which does something at
> compile-time isn't going to do it at run-time, by definition.  My
> example above for explicit phasing is equivalent to:
>
> (library (foo)
>  (export x)
>  (import (rnrs)
>          (for (macro-helper) expand))
>  (define-syntax s
>    (lambda (stx) (helper stx)))
>  (define x (s))
>  (display "(foo) invoked\n"))
>
> and PLT does *not* instantiate (macro-helper) at run-time:
>
> $ cat macro-helper.sls
> #!r6rs
> (library (macro-helper)
>  (export helper)
>  (import (rnrs))
>  (define (helper _) 1)
>  (display "(macro-helper) invoked\n"))
> $ cat foo.sls
> #!r6rs
> (library (foo)
>  (export x)
>  (import (rnrs)
>          (for (macro-helper) expand))
>  (define-syntax s
>    (lambda (stx) (helper stx)))
>  (define x (s))
>  (display "(foo) invoked\n"))
> $ cat use-foo.sps
> (import (rnrs) (foo))
> (write x) (newline)
> $
> $ plt-r6rs ++path . --compile use-foo.sps
>  [Compiling /home/d/t10/implicit-phasing/use-foo.sps]
>  [Compiling /home/d/t10/implicit-phasing/foo/main.sls]
>  [Compiling /home/d/t10/implicit-phasing/macro-helper/main.sls]
> (macro-helper) invoked
> (macro-helper) invoked
> $ plt-r6rs ++path . use-foo.sps
> (foo) invoked
> 1
> $
> $ ikarus --compile-dependencies use-foo.sps
> (macro-helper) invoked
> Serializing "./foo.sls.ikarus-fasl" ...
> Serializing "./macro-helper.sls.ikarus-fasl" ...
> $ ikarus --r6rs-script use-foo.sps
> (foo) invoked
> 1
> $
>
>> > Extrapolate this example to an import set (including all its transitive
>> > imports) with multiple libraries utilized only at (> phase 0) -- do you
>> > really want those libraries instantiated and consuming memory at
>> > run-time even though that's totally unnecessary?
>>
>> Yes, all the languages I know work in this way, and nobody
>> complains about the waste of memory.

I am back from the Python conference and I have re-read this thread
with a fresh mind. I see that I made a factual mistake here answering
"Yes" to a question where you were talking explicitly about runtime
("Do you really want those libraries instantiated and consuming
memory at run-time even though that's totally unnecessary?").
I apologize, I should have answered "No".
I was tired, with other things to do and I did not
pay enough attention to your argument. So let's try again,
and see what other mistake I will put in this time ;-)

I asked Fujita if there is a way to compile an Ypsilon script
separately, to see what happens at compile time and what happens
at runtime explicitly. He answered with this code:
http://codepad.org/t8j2Ev9X

So I tried your own example with Ypsilon, to see if Ypsilon was
instantiating the macro-helper library only at compile time or even at
runtime. Here is the result:

$ ypsilon
Ypsilon 0.9.6-update3 Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "debug.scm")
> (expand-r6rs "/home/micheles/gcode/scheme/use-foo.ss")
(macro-helper) invoked
(foo) invoked
> (run-r6rs "/home/micheles/gcode/scheme/use-foo.ss")
1

So Ypsilon is instantiating the macro-helper, but only at compile-time.
This is still different from what Ikarus and PLT do, because they instantiate
the macro-helper only at the time of the separate compilation of foo.sls
and not again at the time of the compilation of the script use-foo.ss.
This is the "waste" I was ok with, but actually I wrote that I was fine even
with re-instantiating the macro-helper at run-time and that was my
mistake.

    Michele

Reply via email to