I am writing a toy Scheme compiler in Guile, and part of the design is to dynamically bind system-specific procedures to a generic ones so as to improve the system independence. The intention is to have a pair of macros which take a system enum and a
list of bindings, and use them to a) create the export list for the system-specific modules, b) generate a corresponding list of system-independent names which can then c) be bound to the system-dependent imports at runtime.
The relevant code for the first macro is:
(define (append-specific patch item)
(string->symbol
(string-append
(symbol->string patch)
(string-append "-"
(symbol->string item)))))
(define-syntax map-specific
(syntax-rules ()
((_ patch reconciliations)
(let* ((expanded-patch (make-list (length reconciliations) patch))
(patched (map append-specific expanded-patch reconciliations)))
(eval `(export ,@patched) (interaction-environment))))))
And it is invoked at the end of the system-specific module for AMD64 code thusly:
(map-specific (supported-isa amd64) isa-reconciliations)
Where isa-reconciliations is a list of procedure names.
Unfortunately, while the macros I wrote compile correctly, the do not seem to actually generate the exports correctly; when I (use-modules) in the REPL to get the imports of the system-dependent procedures, they do not actually get imported.
The full code is at
https://github.com/Schol-R-LEA/Petty-Scheme/blob/refactoring-file-interface/petty/reconciliations.scm and
https://github.com/Schol-R-LEA/Petty-Scheme/blob/refactoring-file-interface/petty/amd64.scm
I am assuming that the macro in question is not correct. Can anyone offer any advice on this matter?
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)