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: nested macro invocation problem


Oops! The file bug.scm I've attached to my previous message has a lot of (commented out though) unrelated stuff.
For the sake of clarity ignore these files and see this message attachments instead.


In addition to the subject: if I place all macro definitions in one file, everything compiles Ok.

Vladimir Tsichevski wrote:

Hi,

just bumped onto another trouble with macros defined with define-syntax. I have two macros defined in
different scheme files. The first macro is named symbol-append, it is defined in bug1.scm. The second is
defined in bug.scm and uses the first macro in its syntax-rules clauses. The contents of bug1.scm is
made accessible with `require' clause.


The problem is in that the first macro is not expanded as it should, but invalid code sequence is generated
(an attempt is made to treate macro as procedure
and macro object is used instead of macro name, which causes java.lang.VerifyError to be thrown.


Here is java code produced from bug.class:

   public final Macro $Prvt$symbol$Mnappend = bug1.symbol$Mnappend;
...    public final void apply(CallContext $ctx) {
...
   gnu.mapping.Procedure procedure
       = Interpreter
         .getSymbolProcedure(/*TYPE_ERROR*/ $Prvt$symbol$Mnappend);

Regards,
Vladimir

Vladimir
;; -*-scheme-*-

(define-syntax symbol-append
  (syntax-rules ()
    ((symbol-append s1 s2 ...)
     (invoke (make <java.lang.StringBuffer>) 'append s1))))
;; -*-scheme-*-

(require <bug1>)
(define-syntax bug
  (syntax-rules ()
    ((bug s1 s2)
     (symbol-append s1 s2))))

(bug 'a 'b)

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