This is the mail archive of the kawa@sourceware.org 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: Problem with macro expansion


On 11/25/2009 03:38 AM, Colin Fleming wrote:
(token open-vector "#(")

(define-syntax token
   (syntax-rules () ((_ name desc)
                     (define-constant name :: IElement (Element:new desc)))))

The (define-constant open-vector :: IElement (Element:new "#(")) is
what I'd like to make a macro out of, which should result in being
able to use the form (token open-vector "#(").

In the REPL this works, but when I try to compile the class, I get the error:

(compiling Tokens.scm to scheme.Tokens)
Tokens.scm:9:1: define-constant is only allowed in a<body>

The error message is confusing, but the problem appears to be because you have a macro usage before the macro application. In general that doesn't work, especially in this case where the macro expands into a definition. -- --Per Bothner per@bothner.com http://per.bothner.com/


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