[plt-scheme] A silly meta-macro problem...

From: Jerzy Karczmarczuk (karczma at info.unicaen.fr)
Date: Mon Jan 13 07:18:28 EST 2003

I wanted to make a small experiment in order to get rid of the
(send obj meth pars) syntax in such a way:

The macro
(create-something foobar par1 par2 par3)

1. Create the object: (define foobar (make-object something% par1 ...))
    [I know which object, "something" here is a known lexical form,
     "something%" too. foobar is one of many possible instances.]
2. Then, construct a macro "foobar:" which behaves as follows:
    (foobar: meth p1 p2 p3)
    should be transformed into (send foobar meth p1 p2 ...)

[Please, I know I could do this differently. I want to solve *this*

This attempt:

(require (lib "defmacro.ss"))

(define-macro make-something
   (lambda (name . params)
     (let ((name: (string->symbol (string-append (symbol->string name) ":"))))
          (define ,name (list "dummy object just for testing" ',params))
          (define-macro ,name: (lambda pars `(send ,,name  , at pars)))

doesn't work. The expression (make-something foo a b c d) works OK
and produces something. The entity foo is there, a list as abowe.
An attempt to expand foo: blocks, saying that foo doesn't exist.

That's alright, I read the doc, I know about the separation between
the top-level and the transformer environments. Vive la hygiène...

Now, please, tell me what to do. The suggestion that sometimes
one has to put the top-level definitions into a module, and then
use require-for-syntax form seems, beyond my little horizon in this
context. Perhaps I could define foo inside the transformer env,
and then export it out, but I don't know how.

Please help me, Good People.

Jerzy Karczmarczuk
Caen, France

Posted on the users mailing list.