Hi
I'm writing a macro similar to this
(struct field (x y z) )
(struct message (name field-list))
(define-syntax (field-syntax stx)
(syntax-parse stx
([_ field:field_binding]
#`(begin
(field 1 2 5)))))
(define-syntax (message-syntax stx)
(syntax-parse stx
([_ name field:field_binding ...]
#`(begin
(define message-inst (message 'name '((field-syntax field) ...)))))
I want the message object to contain the name and a list of field objects.
However the object is being created with name and list of (field-syntax field)
objects. I then changed the template to use
(with-syntax [ field-list (map field-syntax (syntax->list #'(field ...))) ]
and
(define message-inst (message 'name field-list))
but then it complains that
field-syntax: undefined;
cannot reference an identifier before its definition
phase: 1
explanation cannot access the syntax binding for run-time expressions
I'm a bit confused. When can a macro call a function or another macro. When can
these calls be within template and when can they be moved out.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.