Closed Marie-Joseph closed 5 months ago
fwiw the workaround to this issue is to use R7RS-style library definitions even within the Guile branch. Guile accepts this just fine. However, this still feels like it shouldn't be necessary.
(and from the Guile side, Guile should accept .sld
files by default but doesn't without the right flags, so you have to have a library/module definition at the top of the .scm
file anyway. just so y'all know I'm not picking on Chibi ;) )
cond-expand
is evaluated during expansion time, which happens after reading. Any R7RS implementation is free to reject the code posted in the beginning. The correct way is to use include
in the cond-expand
branch. The file which include
references won't be read if that cond-expand
branch is not evaluated.
Yes, this is working as expected. To be able to process the cond-expand
form we need to be able to read it first, and the #:
syntax is not valid R7RS. include
allows you to conditionally load code with non-portable read syntax.
Alternatively, use a separate module file for Guile.
(define-library (polyglot)
(import (scheme base)
(scheme write))
(include "polyglot-impl.scm")
(export test))
(define-module (polyglot)
#:export (test))
(include-from-path "polyglot-impl.scm")
(define (test)
(display "Worked")
(newline))
Thanks for the guidance!
Hello,
I want to make a library initially written in Guile portable across R7RS-compliant Schemes. I've figured out a basic prototype for library/module declarations that seems to work with Guile and Gambit, but fails with Chibi because of a reader error when encountering a Guile-style module declaration inside a Guile-specific branch of a
cond-expand
. Here's the actual code inpolyglot.scm
:and the associated
polyglot.sld
:Here's a session attempting to import this in the Chibi REPL:
And here's what happens when one uses
-m
:I've tested this against the version of Chibi currently in Guix (0.10) and with a custom package using code from commit 29dd1a3b81e297033f687cbbf2b51319856647f4; both have the same output.