This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
question about macros and Kawa
- From: John Whittaker <john dot whittaker at kc dot rr dot com>
- To: kawa at sources dot redhat dot com
- Date: Tue, 01 Jun 2010 23:39:20 -0500
- Subject: 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.