So, I was reading again the R6RS document, especially the part about
phase separations which I had dismissed in the past, and I have found
the following sentence:
"""
An implementation may distinguish instances/visits of a library for
different phases or to use an instance/visit at any phase as an
instance/visit at any other phase. An implementation may further
expand each library form with distinct visits of libraries in any
phase and/or instances of libraries in phases above 0. An
implementation may create instances/visits of more libraries at more
phases than required to satisfy references. When an identifier appears
as an expression in a phase that is inconsistent with the identifier’s
level, then an implementation may raise an exception either at expand
time or run time, or it may allow the reference. Thus, a library whose
meaning depends on whether the instances of a library are
distinguished or shared across phases or library expansions may be
unportable.
"""
Basically the R6RS module system does not guarantee portability, which
I thought was the point of it :-( I feel depressed, but let it be.
Now, I was experimenting with phase separation. Here is an example
that works with PLT Scheme:

$ cat test1.sls
(library (test1 helper1)
(export hello sub)
(import (rnrs))

(define-syntax sub
  (syntax-rules ()
    ((_ pattern template) (syntax-rules () (pattern template)))))

(define (hello)
  "hello!")
)
(library (test1)
(export hello world)
(import (rnrs)
        (for (only (test1 helper1) sub) expand)
        (for (only (test1 helper1) hello) run))

(define-syntax double
  (sub (_ x) '(x x)))

(define (world)
  (display (hello)) (display "world "))

(display (double 1))
)

Of course, this example does not work with Ikarus with error "expected
to find library (test1) in file ./test1.sls, found (test1 helper1)
instead"
Should I give up the idea of keeping the library in a single file?
This is unfortunate, I thought this was a feature of the R6RS module
system. Any hint is much appreciated :-/

Reply via email to