On Apr 28, 2009, at 9:51 AM, Michele Simionato wrote:
On Mon, Apr 27, 2009 at 7:14 PM, Abdulaziz Ghuloum
<[email protected]> wrote:
2. The statement "but it is not possible to instantiate modules at
runtime
only or at expand time only" is false. You can definitely
instantiate a
module for one phase and not another in Ikarus and the other
psyntax-based
implementations.
Really? Is there a special syntax for that?
No syntax! That's the whole point. :-)
I was convinced by this example
(import (rnrs) (for (only (aps list-utils) distinct?) expand))
(display distinct?);; here distinct is available even at runtime even
if I imported it at expand time
that it was impossible.
You already know that Ikarus simply ignores the "for" thingy you
have up there, so, your import is no different from writing
(import (rnrs) (only (aps list-utils) distinct?))
Right?
Since it appears I was mistaken, I am very curious of how do
you instantiate a module at expand time only or at runtime only in
psyntax systems.
If a piece of code contains (after expansion) a reference to
variable X defined in library (FOO), then that library is
invoked before this expanded code is evaluated. The code
here might be the expression of a syntax definition in library
(BAR), and in that case (FOO) is invoked when the syntax
definition is evaluated (i.e., when (BAR) is expanded and/or
visited). The code might also be in a variable definition or
initializing expressions, and in that case (FOO) is invoked
when (BAR) is invoked. Example:
$ cat FOO.sls BAR.sls t.sps
#!r6rs
(library (FOO)
(export x)
(import (rnrs))
(define x 12)
(display "FOO is invoked\n"))
#!r6rs
(library (BAR)
(export y)
(import (rnrs) (FOO))
(define-syntax mac
(lambda (stx) (+ x x))) ;;; used in a macro definition only
(define y (mac)) ;;; this is like (define y 24)
(display "BAR is invoked\n"))
#!r6rs
(import (rnrs) (BAR))
(display y)
(newline)
$ ikarus --compile-dependencies t.sps
FOO is invoked
Serializing "./BAR.sls.ikarus-fasl" ...
Serializing "./FOO.sls.ikarus-fasl" ...
$ ikarus --r6rs-script t.sps
BAR is invoked
24
See, FOO is invoked only at expansion/compile time and not at
run time.
Aziz,,,