This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use define-simple-class in macros?



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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]