This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Another macro/module question related to implementing srfis.
- To: guile at sourceware dot cygnus dot com
- Subject: Another macro/module question related to implementing srfis.
- From: Rob Browning <rlb at cs dot utexas dot edu>
- Date: 18 Jan 2000 11:48:57 -0600
I'd like to be able to use srfi-0 (cond-expand) to implement as many
of the srfis as possible (when possible and desirable) using common
code and "cond-expanding" the implementation specific bits. This,
however, is turning out to be more problematic than I initially
suspected[1].
The problem I've run into now is that I'd like to be able to say
things like this (presume that cond-expand is already defined):
(cond-expand
(guile
(define-module (srfi srfi-8)
:use-module (ice-9 slib))
(require 'macro-by-example)
(require 'values))
(else)) ; Nothing
The natural expansion of this (when you're in guile) would be:
(begin
(define-module (srfi srfi-8)
:use-module (ice-9 slib))
(require (quote macro-by-example))
(require (quote values)))
But when you try to load this via (use-modules (srfi srfi-8)), you get
an error that I don't fully understand, but I suspect has something to
do with "begin" interfering with the module system:
$ (cd build/guile && guile)
guile> (begin
(define-module (srfi srfi-8)
:use-module (ice-9 slib))
(require (quote macro-by-example))
(require (quote values)))
standard input:4:5: In expression (require (quote macro-by-example)):
standard input:4:5: Unbound variable: require
ABORT: (misc-error)
Type "(backtrace)" to get more information.
guile>
Am I doing something wrong here, or is this just a problem with the
current implementation?
Thanks
[1] One uncomfortable problem is that cond-expand isn't specified to
work in anything other than at the "top-level", so you can't do things
like this:
(define (foo bar)
;; Implement fast helper functions for each implementation...
(cond-expand
(guile
(define (optimized-helper baz) ...))
(rscheme
(define (optimized-helper baz) ...))
;; RXRS default helper
(else
(define (optimized-helper baz) ...)))
...)
--
Rob Browning <rlb@cs.utexas.edu> PGP=E80E0D04F521A094 532B97F5D64E3930