[gambit-list] Macros, separate files, and all that

Bradley Lucier lucier at math.purdue.edu
Thu Jan 31 14:34:17 EST 2013


On Jan 31, 2013, at 2:25 PM, Marc Feeley wrote:

> 
> I don't have access to your code, but it looks like you have a phasing problem.

Here's the code.

>  The macro definition needs to be available when code that uses the macro is compiled (because the macro's body needs to be executed to perform the code transformation).  What I usually do in such cases is to split the source code in two parts "streams#.scm" which contains the macro definitions and "streams.scm" which contains the rest of the code (function definitions).  Then the file "sieve.scm" should *include* the file "streams#.scm".  That way, the files "streams.scm" and "sieve.scm" can be compiled separately.  I'm sure you will notice the similarity with the C model (which separates ".h" and ".c" files).
> 
> Please check examples/distr-comp and specifically "dc.scm" and "dc#.scm" for an example.

I understand what you're saying, I understand your coding style.

What I don't understand is why, if I load the source (*.scm) of the macros into the REPL of gsc, the macros are available to expand the source of later files during compilation, while if I load the compiled (*.o*) versions of the same file into the REPL of gsc, those macros are *not* available to expand the source of later files during compilation.  (I think I gave sufficient examples to illustrate this in my previous e-mail.

Brad

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sieve.scm
Type: application/octet-stream
Size: 613 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130131/018778de/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streams.scm
Type: application/octet-stream
Size: 23315 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130131/018778de/attachment-0001.obj>


More information about the Gambit-list mailing list