question about macros and Kawa
John Whittaker
john.whittaker@kc.rr.com
Wed Jun 2 04:39:00 GMT 2010
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.
More information about the Kawa
mailing list