* boot-9.scm (module-defined?): New function.
authorMarius Vollmer <mvo@zagadka.de>
Thu, 27 Feb 1997 15:36:04 +0000 (15:36 +0000)
committerMarius Vollmer <mvo@zagadka.de>
Thu, 27 Feb 1997 15:36:04 +0000 (15:36 +0000)
(macroexpand-1, macroexpand): Use local-ref instead of defined?
and eval.
* r4rs.scm (%load-verbosely): Use "module-defined?" instead of
"defined?".
* slib.scm (defined?): New function to take the place of the
builtin "defined?".  It allways examines the slib module.

ice-9/boot-9.scm
ice-9/r4rs.scm
ice-9/slib.scm

index 2decf16..6cae918 100644 (file)
        (variable-set! variable value)
        (module-add! module name (make-variable value name)))))
 
+;; MODULE-DEFINED? -- exported
+;;
+;; Return #t iff NAME is defined in MODULE (or in a module that MODULE
+;; uses)
+;;
+(define (module-defined? module name)
+  (let ((variable (module-variable module name)))
+    (and variable (variable-bound? variable))))
+
 ;; MODULE-USE! module interface
 ;;
 ;; Add INTERFACE to the list of interfaces used by MODULE.
 ;;   
 ;;   "ice-9 gtcltk" is the C version of the module name. Slashes are
 ;;   replaced by spaces, the rest is untouched. `scm_init_gtcltk' is
-;;   the real init function that executes the usual initilizations
+;;   the real init function that executes the usual initializations
 ;;   like making new smobs, etc.
 ;;
 ;; - Make a shared library with your code and a name like
         (lambda args
           #f)))
 
+(define (dynamic-maybe-link filename)
+  (catch #t                            ; could use false-if-exception here
+        (lambda ()
+          (dynamic-link filename))
+        (lambda args
+          #f)))
+
 (define (find-and-link-dynamic-module module-name)
   (define (make-init-name mod-name)
     (string-append 'scm_init
      %load-path)))
 
 (define (link-dynamic-module filename initname)
-  (let ((dynobj (dynamic-link filename)))
-    (if (dynamic-maybe-call initname dynobj)
-       (set! registered-modules (append! (convert-c-registered-modules dynobj)
-                                         registered-modules))
-       (dynamic-unlink dynobj))))
-
+  (let ((dynobj (dynamic-maybe-link filename)))
+    (if dynobj
+       (if (dynamic-maybe-call initname dynobj)
+           (set! registered-modules 
+                 (append! (convert-c-registered-modules dynobj)
+                          registered-modules))
+           (begin
+             (pk 'no_init)
+             (dynamic-unlink dynobj))))))
+           
 (define (try-module-dynamic-link module-name)
   (or (init-dynamic-module module-name)
       (and (find-and-link-dynamic-module module-name)
           (init-dynamic-module module-name))))
 
+
+
 (define autoloads-done '((guile . guile)))
 
 (define (autoload-done-or-in-progress? p m)
              (lambda (exp env)
                (copy-tree (apply f (cdr exp)))))))
 
+
+;; XXX - should the definition of the car really be looked up in the
+;; current module?
+
 (define (macroexpand-1 e)
   (cond
    ((pair? e) (let* ((a (car e))
-                    (val (and (symbol? a) (defined? a) (eval a))))
+                    (val (and (symbol? a) (local-ref (list a)))))
                (if (defmacro? val)
                    (apply (defmacro-transformer val) (cdr e))
                    e)))
 (define (macroexpand e)
   (cond
    ((pair? e) (let* ((a (car e))
-                    (val (and (symbol? a) (defined? a) (eval a))))
+                    (val (and (symbol? a) (local-ref (list a)))))
                (if (defmacro? val)
                    (macroexpand (apply (defmacro-transformer val) (cdr e)))
                    e)))
index 696ba40..86fcbf2 100644 (file)
 \f
 ;;;; Loading
 
-(if (not (defined? '%load-verbosely))
+(if (not (module-defined? (current-module) '%load-verbosely))
     (define %load-verbosely #f))
 (define (assert-load-verbosity v) (set! %load-verbosely v))
 
index 0e717db..c7ef4ee 100644 (file)
 (define slib:tab #\tab)
 (define slib:form-feed #\page)
 
+(define slib-module (current-module))
+
+(define (defined? symbol)
+  (module-defined? slib-module symbol))
+
 (define slib:features
   (append '(source
            eval
                '()))))
 
 
-(define slib-module (current-module))
-
 (define (slib:load name)
   (save-module-excursion
    (lambda ()