guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Planning work


From: Rob Browning
Subject: Re: Planning work
Date: 09 May 2001 22:44:44 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Rob Browning <address@hidden> writes:

> Now I can go play some more.  I'll just have an explict "my-compile"
> (or whatever) command for now.

So it looks like I can get hold of the expanded sexps by writing a
function similar to syncase.scm's eval that uses sc-expand
appropriately, and then those forms can be written out to a file and
handed to hobbit.

But that's hardly a start.

After getting that far, I realized that I really haven't fully thought
through the semantics of macros when we have fully separate
compilation and execution stages.

For example, given this code:

  (define (baz)
    (display "Hello\n"))

  (define-macro (foo bar)
    (baz)
    bar)

  ...

  (define (echo-func x)
    (foo x))

  (echo-func #f)

What should happen at compile time and what should happen at run-time?

And of course, if the ... indicates that the code lies in separate
files, presumably accessed by a load, or use-modules, or whatever,
then I suppose the compiler needs to know about how to load and
properly handle sub-files of the file being compiled since it will
need the macro definitions in the sub-files for expansion purposes,
and may also need *some* of the function definitions, at least any
that are used during some macro's expansion process.

Overall this seems to argue that if you're trying to compile a.scm
that depends on (via load or use-modules) b.scm and c.scm, you have to
actually fully load each of those too at compile time, even if you're
just trying to compile a.scm.  However I suspect that there is a lot
of code out there where b.scm and c.scm may take actions that are
*not* appropriate at compile time at the top-level, or perhaps during
macroexpansion.  Is the answer in such cases just that the code is
"broken" and needs to be re-written to use eval-when properly?

i.e. should the code above just be rewritten as

  (define (baz)
    (display "Hello\n"))

  (define-macro (foo bar)
    (baz)
    bar)

  ...

  (define (echo-func x)
    (foo x))

  (eval-when 'eval
    (echo-func #f)

(presuming that eval-when 'eval means "run this only at eval-time".)

I just want to check my thinking here.  It's been a while since I used
a lisp-family language that actually had separate compilation and
execution stages...

Thanks

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]