This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
extending `process-define-module'
- To: guile at sourceware dot cygnus dot com
- Subject: extending `process-define-module'
- From: thi <ttn at mingle dot glug dot org>
- Date: Sat, 2 Oct 1999 21:38:11 -0700
- Reply-to: ttn at netcom dot com
hello,
i would like to submit the following patch for consideration for
inclusion in guile. it adds a var `process-define-module-hook' and
extends `process-define-module' to consult that var as a list of keyword
handlers. this allows easy extension of `define-module'. for example:
(set! process-define-module-hook (make-hook 2)) ; can move to boot-9.scm
(add-hook! process-define-module-hook
(lambda (kws reversed-interfaces)
(cond ((eq? ':weird-word (car kws))
(write-line (cadr kws))
(cons (cddr kws) reversed-interfaces))
((eq? ':another-weird-word (car kws))
(write-line (cadr kws))
(write-line (caddr kws))
(write-line (cadddr kws))
(cons (cddddr kws) reversed-interfaces))
(else
#f))))
(define-module (simple test)
:weird-word (weird stuff)
:another-weird-word (with) (even-more) (weird stuff)
:use-module (ice-9 regex)
:autoload (ice-9 common-list) (reduce)
)
this is a contrived example for test purposes. what i really want to
write (that this patch enables) is something along the lines of
`:exporting-autoload', i.e., a convolution of `export' and `:autoload'.
feedback appreciated!
thi
-------------------------
cd /usr/local/share/guile/1.3.4/ice-9/
diff -u ~/local/src/guile-1.3.4/ice-9/boot-9.scm boot-9.scm
--- /home/ttn/local/src/guile-1.3.4/ice-9/boot-9.scm Sat Oct 2 21:14:32 1999
+++ boot-9.scm Sat Oct 2 20:58:27 1999
@@ -1924,6 +1924,8 @@
(define %autoloader-developer-mode #t)
+(define process-define-module-hook #f)
+
(define (process-define-module args)
(let* ((module-id (car args))
(module (resolve-module module-id #f))
@@ -1977,7 +1979,30 @@
(set-system-module! module #t)
(loop (cdr kws) reversed-interfaces))
(else
- (error "unrecognized defmodule argument" kws))))))
+ (cond (process-define-module-hook
+ => (lambda (hook)
+ (catch
+ 'unrecognized-defmodule-arg
+ (lambda ()
+ (catch
+ 'arg-ok
+ (lambda ()
+ (for-each
+ (lambda (handler)
+ (cond ((handler
+ kws
+ reversed-interfaces)
+ => (lambda (res)
+ (throw 'arg-ok res)))))
+ (hook->list hook))
+ (throw 'unrecognized-defmodule-arg))
+ (lambda (sym res)
+ (loop (car res) (cdr res)))))
+ (lambda dummy
+ (error "unrecognized defmodule argument"
+ kws)))))
+ (else
+ (error "unrecognized defmodule argument" kws))))))))
module))
;;; {Autoload}
Compilation exited abnormally with code 1 at Sat Oct 2 21:16:18