[plt-scheme] Interesting module/macro interactions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 13 09:10:30 EST 2003

At Thu, 13 Feb 2003 03:41:52 -0800 (PST), Noel Welsh wrote:
> (define-assertion (name param ...) body ...)
> 
> expands into
> 
> (begin
>   (define-syntax (name param ...) body ...)
>   (define (name* param ...) body ...))
> 
> Note that name is defined as a macro, and name* as a
> function (for those times when you want to use
> assertions as functions).

Assuming that you want name* to be usable by the supplier of name...

> (with-syntax (((reported-name function-name)
>                (let ((reported-name 
>                       (symbol->string (syntax-object->datum (syntax name)))))
>                  (list reported-name 
>                        (string->symbol (string-append reported-name "*"))))))
                         -------------------------------------------------

... give the generated identifier name* the same lexical context as
name:

 (datum->syntax-object
  (syntax name)
  (string->symbol (string-append reported-name "*"))))

If I understand correctly, that should fix both of the problems you
saw.

Matthew



Posted on the users mailing list.