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]

question about macros and Kawa


Why is it that I cannot use Kawa's shorthand (and normal) method
invocation syntax in my macros, but the old-style or more primitive
"invoke" works?  I suspect this is something I am not getting about
syntax-case since it is usually a brain bender for me :). 

Here is a simple example:

Suppose I have a class called junk and I want to define a macro that
makes an instance of junk.  Never mind that I can already do this with
the init-keywords in the class definition syntax of Kawa.  This is just
simpler version of a more complicated case that I have.

(define-simple-class junk ()
  (f1)
  (f2)
  )

(define-syntax make-junk
  (lambda (stx)
    (syntax-case stx ( f1: f2:  )
                 ((make-junk f1: the-command f2: subcommand)
                  (datum->syntax-object
                   (syntax make-junk)
                   `(let* ((c (make junk)))
                      (set!  (field c "f1") ,(syntax-object->datum
(syntax the-command)))
                      (set!  (field c "f2") ,(syntax-object->datum
(syntax subcommand)))
                      c))))))

It would be much more obvious to me if my define-syntax looked like this:

(define-syntax make-junk
  (lambda (stx)
    (syntax-case stx ( f1: f2:  )
                 ((make-junk f1: the-command f2: subcommand)
                  (datum->syntax-object
                   (syntax make-junk)
                   `(let* ((c (make junk)))
                      (set!  (*:.f1 c)  ,(syntax-object->datum (syntax
the-command)))
                      (set!  (*:.f2 c) ,(syntax-object->datum (syntax
subcommand)))
                      c))))))



Thanks,

John Whittaker  

By the way, I just love Kawa.  I only wish I could get the Eclipse Java
debugger to work with it again.  JSwat sort of works, but the Eclipse
debugger with Schemescript would be ohhh so nice.


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