I'm running into a problem creating custom languages that compile to Scheme. I have an example here of a simple compiler that takes any Scheme expression and generates code for creating a Guile module. If I compile a file using this language and reference the resulting module from another one that's just written in normal Scheme, it works the first time when the normal Scheme file gets autocompiled and then fails subsequently when the cached compiled Scheme file is loaded, telling me that any reference I make to a symbol defined in (guile) from my compiled non-Scheme module is undefined.
This is rather hard to explain, so I've tried to boil this down to a couple really short files. First, this is the language spec: (define-module (language test-lang spec) #:use-module (system base language) #:export (test-lang)) (define (compile-scheme exp env opts) (values `(begin (define-module (test-lang lang)) (display (+ 1 2))) env env)) (define-language test-lang #:title "test-lang" #:reader (lambda (port env) (read port)) #:compilers `((scheme . ,compile-scheme)) #:printer write) All it does is take any arbitrary expression and generate a scheme module that when loaded will display the number 3 (just for the sake of an example). I created a file test-lang/lang.scm with one expression in it and compiled it. That created a cached .go file that defined the module. Then I wrote the following script and ran it: #! /home/mark/build/guile-2.0/bin/guile -s !# (use-modules (test-lang lang)) (display "Success") The first time, it displayed 3 and then "Success". The second time I got an error while it was doing primitive-load-path for test-lang/lang.scm.go, telling me that 'display' is undefined. Does anyone know if this is a problem with the compiler or am I not using it propertly? I'm still not very clear on how compiled files reference their environments. It seems like the module defined in my non-Scheme file is completely empty when it gets loaded from another compiled file. This happens with my xml-xcb binding language as well, which makes it hard to write applications that actually use it! I've been stuck including --fresh-auto-compile in my scripts, which is not a very good solution for the long term. Thanks -- Mark Witmer