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]

Use define-simple-class in macros?


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)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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