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: question about macros and Kawa


Hmmm.  My example with the f1:c does not cause an error when invoked, but it doesn't work either.
Unfortunately, neither does this:

(define-syntax make-junk3
   (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!  c:f1 ,(syntax-object->datum (syntax the-command)))
                      (set!  c:f2 ,(syntax-object->datum (syntax subcommand)))
                      c))))))

I can invoke make-junk3 and get an instance of junk back.  But the fields f1 and f2, which should have been set to the values passed, are #!null.  See below for an example.

#|kawa:87|# (set! me (make-junk3 f1: 2 f2: 3))
#|kawa:88|# me
junk@10a3b24
#|kawa:89|# me:f1
#!null
#|kawa:90|# me:f2
#!null

On the other hand,  the original and verbose make-junk works as expected:

(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))))))

#|kawa:66|# (set! you (make-junk f1: 4 f2: 5))
#|kawa:67|# you
junk@27e353
#|kawa:68|# you:f1
4
#|kawa:69|# you:f2
5


Thanks,

John Whittaker




----- Original Message ----
> From: Per Bothner <per@bothner.com>
> To: John Whittaker <john.whittaker@sbcglobal.net>
> Cc: kawa@sources.redhat.com
> Sent: Wed, June 2, 2010 10:19:06 AM
> Subject: Re: question about macros and Kawa
> 
> On 06/02/2010 07:17 AM, John Whittaker wrote:
> Per,
>
> Yes, 
> indeed, your suggestion regarding [f1:c] syntax works.

Hm.  I meant 
> to write:

(set!  c:f1 ...)

I.e. set the field property named 
> f1 of the object c.
-- 
    --Per Bothner

> ymailto="mailto:per@bothner.com"; 
> href="mailto:per@bothner.com";>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]