This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Use define-simple-class in macros?
- From: William Shulman <will at mercedsystems dot com>
- To: David O'Callaghan <david dot ocallaghan at cs dot tcd dot ie>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Tue, 21 Jun 2005 11:35:20 -0700
- Subject: Re: Use define-simple-class in macros?
- References: <42B85CEB.7070901@cs.tcd.ie>
maybe you just have a typo in this email, but do you intend there to
be two open parens after the '`' in the body of your macro definition?
-will
David O'Callaghan writes:
> Hi,
>
> Probably a very basic question, but should it be possible to use
> define-simple-class in a macro? If I define a simple macro that uses
> define-simple-class I get an error when I try to call it:
>
> define-simple-class can only be used in <body>
>
> But if I manually do the macro substution the program works fine.
>
> Thanks,
>
> David
>
> ;; define-operator macro
> (defmacro define-operator (name operator)
> `((define-simple-class ,name ()
> ((execute . operands)
> (apply ,operator operands)))))
>
>
> ;; non-macro version
> (define-simple-class <plus> ()
> ((execute . operands)
> (apply + operands)))
>
> ;; macro version
> (define-operator <plus> +)
>
> (define five (invoke (make <plus>) 'execute 2 3))
> (display five)