[plt-scheme] Unit/sig and hygiene

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Thu Sep 28 05:54:36 EDT 2006

Hi all,

We have a problem with the interaction between signed units and  
hygiene.  Our problem is this:

Module A defines syntax that expands into:

   - define-values/invoke-unit/sig
   - some macros that refer to bindings introduced by define-values/ 

A small fragment is below.  The with-database macro expands to a call  
to call-with-database, which is defined in the snooze^ signature.

   (define-syntax (define-snooze-interface stx)
     (syntax-case stx ()
       [(define-snooze-interface db@)

              ; The main snooze^ interface:
              (define-values/invoke-unit/sig snooze^
                  (link (db : db^ (db@))
                        (snooze : snooze^ (snooze@ db)))
                  (export (open snooze))))

              ;; syntax (with-database (config) expr ...)
              ;; Convenience form for call-with-database.
              (define-syntax (with-database stx)
                (syntax-case stx ()
                  [(_ (config) expr (... ...))
                   #'(call-with-database config (lambda () expr  
(... ...)))]))

               ; etc ...


Module B calls define-snooze-interface:

   (module b mzscheme
     (require a)
     (provide (all-defined))
     (define-snooze-interface a-db))

Module C requires B and attempts to use with-database.  We receive an  

   reference to undefined identifier: call-with-database

The problem, we think, is that define-values/invoke-unit/sig  
unhygienically introduces bindings, so these bindings are not  
apparent at the definition time of the with-database macro, so the  
call-with-database name does not refer to the binding introduced by  
the define-values/invoke-unit/sig form.

So we think we know the problem, but we don't know how to solve it.   
All help appreciated!


Dave & Noel

Posted on the users mailing list.