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

uinterned symbols perhaps?



I'm reading Dybvig's paper: "Writing Hygienic Macros in Scheme with
Syntax-Case"

Anyway, it is a helpful read, and I've been learning quite a bit about the
new macro
system.

Here's an example I've contrived that has me stumped.
Consider this trivial class:

(define foo%
  (class object%
    (public a)
    (define a (lambda () (display 'a) (newline)))
    (super-instantiate ())))

(define obj2 (instantiate foo% ()))
(interface->method-names (object-interface obj2))

--->
(a)
> (send obj2 a) ;<--- works as expected, prints a

So here's a macro:

(define-syntax test-macro
  (lambda (stx)
    (syntax-case stx ()
      ([_ e ...]
       (with-syntax ([(t ...) (generate-temporaries (syntax (e ...)))])
         (syntax
          (class object%
            (public t ...)
            (define t
              (lambda () (display 't) (newline))) ...
            (super-instantiate ()))))))))

(define obj (instantiate (test-macro 'a 'b 'c 'd) ()))
(interface->method-names (object-interface obj))

--->
(g833 g832 g831 g830)
> (send obj g833)
send: no such method: g833 ;<--- yuck I get this error, interface->method
names has let me down.

It would appear that the symbols produced by "generate-temporaries" are of
a different nature than the symbol 'a used in foo%.

Unfortunately, test-macro, while it seems a little contrived, is very
similar
to a real macro I'm trying to write. The "real macro" will produce a proxy
for
a class that I can call remotely. The proxy needs to have all the provided
methods,
and in addition a number of "continuation methods" that will be "called"
when the
real methods in the remote class "return".

All that aside, the crux of the issue is that for n methods, I need to
generate
n additional method names to use in the class. generate-temporaries does
this,
but the symbols are no good. :-(