[plt-scheme] modules, macros, and #%mred-kernel

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Sat Sep 2 15:45:23 EDT 2006

> I am trying to define the following macro:
>
>   (define-syntax (define/ocaml stx)

[macro cut]

> As far as I can tell, it works; that is, when I type it into the 
> toplevel and then type (define/ocaml (test a b c) (send defs insert 
> "hello")), it only says that "tab" is not a valid object (which it 
> isn't). But when I put the same macro into a module, provide it, and 
> require the module from a different one, the same test case fails 
> because "defs" is not defined.

Hi Aleks,

Can you show the literal error message?  I just want to look at the error 
message more closely.


Also, how was the define/ocaml module defined?  Did you do this:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module define-ocaml mzscheme
   (require (lib "class.ss"))
   (provide define/ocaml)

   (define-syntax (define/ocaml stx)
     (syntax-case stx ()
       [(_ (name args ...) body ...)
        (syntax
          (define name
            (lambda (tab args ...)
              (let* ([defs (send tab get-defs)]
                     [ints (send tab get-ints)]
                     [frame (send tab get-frame)]
                     [process-obj (send tab get-debug-process)]
                     [proc (process-proc process-obj)]
                     [in (process-in process-obj)]
                     [out (process-out process-obj)]
                     [err (process-err process-obj)])
                 body ...))))])))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I've added the (require (lib "class.ss")) part because the macro uses the 
SEND form.  On that note, I'm not sure I know where the PROCESS-PROC, 
PROCESS-IN, PROCESS-OUT, or PROCESS-ERR selectors are defined, but the 
macro will probably have to require whatever provides them too.


> It seems like I need to put (require-for-syntax my-module) at the top of 
> the module using this syntax.

I don't think REQUIRE-FOR-SYNTAX is what you want here.


Hope you're doing well!


Posted on the users mailing list.