chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] newbie questions about macros in modules


From: Felix
Subject: Re: [Chicken-users] newbie questions about macros in modules
Date: Thu, 29 Jul 2010 12:39:59 +0200 (CEST)

From: Imran Rafique <address@hidden>
Subject: [Chicken-users] newbie questions about macros in modules
Date: Thu, 22 Jul 2010 16:46:39 -0700

> 2) module io defines a macro (debug-info) and a function (print-info).
> debug-info calls print-info. If module io is imported without a prefix, then
> it works. If module io is imported WITH a prefix, then the macro
> (debug-info) is trying to call a function (print-info) which isn't available
> (only <prefix>print-info is). Is there any way to account for this when
> creating the macro?
> 
> Example code below
> 
> ;;; ---- repl ----
>> (define _debug #t)
>> (load-relative "/home/imran/src/scheme/lib/io.scm")
>> (import (prefix io io/))
>> (io/print-info "blah")
> [lib/io 15:42:43] blah
>> (io/debug-info "blah")
> Error: unbound variable: print-info
> 
>> (import io)
>> (debug-info "blah")
> [lib/io 15:47:00] (debugging) blah
> 

Attached is a patch that should help. The problem was an inconsistency
how the static environment of syntax definitions was created on
import. You can also use the "experimental" branch in the git repository.


cheers,
felix
commit 8a1aa876f2e6656ff868f4c67208bc7f87d137bd
Author: felix <address@hidden>
Date:   Mon Jul 26 16:54:17 2010 +0200

    potential import/rename fix

diff --git a/expand.scm b/expand.scm
index e8c2695..3ca63b7 100644
--- a/expand.scm
+++ b/expand.scm
@@ -1894,7 +1894,7 @@
      (module-undefined-list mod))
     (when missing
       (##sys#error "module unresolved" name))
-    (let* ((exports 
+    (let* ((iexports 
            (map (lambda (exp)
                   (cond ((symbol? (cdr exp)) exp)
                         ((assq (car exp) (##sys#macro-environment)))
@@ -1903,11 +1903,11 @@
           (new-se (merge-se 
                    (##sys#macro-environment) 
                    (##sys#current-environment) 
-                   exports)))
-      (##sys#mark-imported-symbols exports)
+                   iexports vexports sexports sdlist)))
+      (##sys#mark-imported-symbols iexports)
       (for-each
        (lambda (m)
-        (let ((se (merge-se (cadr m) new-se)))
+        (let ((se (merge-se (cadr m) new-se))) ;XXX needed?
           (dm `(FIXUP: ,(car m) ,@(map-se se)))
           (set-car! (cdr m) se)))
        sdlist)
@@ -1915,7 +1915,7 @@
            ,(module-name mod) 
            (DLIST: ,@dlist)
            (SDLIST: ,@(map-se sdlist))
-           (IEXPORTS: ,@(map-se exports))
+           (IEXPORTS: ,@(map-se iexports))
            (VEXPORTS: ,@(map-se vexports))
            (SEXPORTS: ,@(map-se sexports))))
       (set-module-vexports! mod vexports)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]