[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question: 'External references' in compiled scheme files when moving
From: |
Andy Wingo |
Subject: |
Re: Question: 'External references' in compiled scheme files when moving to Guile V2 from V1.8.7 |
Date: |
Wed, 22 Jun 2011 15:46:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
On Tue 21 Jun 2011 22:07, Ian Hulin <address@hidden> writes:
> My question is this:
> some of the .scm files in the list make references to definitions in a
> .scm file loaded previously; When we compile this list of .scm files,
> will we need to load each .go file produced immediately after compiling
> it in order to resolve any external references, or is the byte-compiled
> code smart and defers resolving external references until such time as
> the .go file itself is loaded?
The main change is this:
** Functions needed by macros at expand-time need to be present at
expand-time.
For example, this code will work at the REPL:
(define (double-helper x) (* x x))
(define-macro (double-literal x) (double-helper x))
(double-literal 2) => 4
But it will not work when a file is compiled, because the definition of
`double-helper' is not present at expand-time. The solution is to wrap
the definition of `double-helper' in `eval-when':
(eval-when (load compile eval)
(define (double-helper x) (* x x)))
(define-macro (double-literal x) (double-helper x))
(double-literal 2) => 4
See the documentation for eval-when for more information.
That's from the NEWS. There are some other tidbits there; I recommend
reading the entire 2.0.0 NEWS entry. It's a bit long but all the info
is there.
Regards,
Andy
--
http://wingolog.org/