scsh-users
[Top] [All Lists]

Re: macros and compilation

To: walter@pelissero.org ("Walter C. Pelissero")
Subject: Re: macros and compilation
From: sperber@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor])
Date: Sun, 06 Jan 2002 15:42:04 +0100
Cc: scsh@zurich.ai.mit.edu
>>>>> "Walter" == Walter C Pelissero <walter@pelissero.org> writes:

Walter> I've noticed that macro declarations are not available anymore after
Walter> compilation.  So if I try to load at runtime a Scheme file, that file
Walter> can't make use of the macros I declared to build my VM image.

Walter> I try to explain my problem with an example.  Having foo.scm:

Walter>     #!/usr/local/bin/scsh \
Walter>     -dm -m program -e main -s
Walter>     !#


Walter>     (define-structure program
Walter>       (export main)
Walter>       (open scheme)
Walter>       (begin

Walter>         (define-syntax foo
Walter>           (syntax-rules ()
Walter>             ((foo)
Walter>              1)))

Walter>         (define (main args)
Walter>           (load "bar.scm"))))

Walter> and bar.scm:

Walter>     (display (foo))
Walter>     (newline)

Walter> If I try this, everything is all right:

Walter>     hyde501% scsh
Walter>     Scsh 0.5.3
>> ,config ,load foo.scm
Walter>     foo.scm .
>> ,in program (main '())
Walter>     Load structure program (y/n)? y
Walter>     [program
Walter>     .
Walter>     ]
Walter>     bar.scm 1

Walter>     #f
>> 

Walter> While if I compile foo.scm the macro declaration is not visible
Walter> anymore:

Walter>     hyde501% make foo
Walter>     ./make-scsh-image.scm foo.scm
Walter>     hyde502% ./foo
Walter>     bar.scm 
Walter>     Error: undefined variable
Walter>            foo
Walter>            (package user)
Walter>     Undefined: (foo)
Walter>     hyde503% 

Walter> Is this an intended behaviour or I'm missing something?

LOAD loads into INTERACTION-ENVIRONMENT, not into the PROGRAM
package.  Using LOAD in conjunction with the module system without
explicitly specifying which package to load into is bound to get you
into trouble.

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla

<Prev in Thread] Current Thread [Next in Thread>