This isn’t a direct answer to your question, but as Matthias notes, my
struct-update package already implements a macro that generates
functional setters from structure definitions. Here’s a link to the

Of course, that isn’t especially helpful if your goal is to get better
at authoring macros, not just generate functional setters. For that, you
might find the (short) source code of struct-update helpful, located

Admittedly, your make-functional-setter function does a bit more than
define-struct-updaters, since it allows for a wrapper function. So I’ll
also give some brief answers to a few of your unrelated questions.

> On May 26, 2018, at 10:46, David Storrs <>
> wrote:
> A) Is there a way to test if a syntax class has a particular attribute
> before trying to use it?

Yes, use the attribute form. If x is an optional attribute, (attribute
x) will be #f if the attribute was not bound and the value of the
attribute if it was bound. If you want, you can change the default value
to something else other than #f by providing the #:defaults option to

> B) Alternatively, is there a way to create a null syntax object that
> expands to nothing?  Not (void), not "", literally nothing.   Then I
> could have each pattern bind all the attributes via #:with and just
> have some of them be blank.

Not in an arbitrary context. In a definition context, (begin)
effectively expands into nothing, since begins are spliced into the
enclosing context, but in an expression context, you can’t have
something that expands into nothing.

That said, it sounds like what you might actually want is the template
and ?? forms from syntax/parse/experimental/template. This allows you
to write something like this:

    (template (foo (?? x)))

The above will be like #'(foo x) if (attribute x) is non-#f, but if it
is #f, it will be like #'(foo). In Racket 6.12 and earlier, you must use
the template form for ?? to work, but in Racket 7 and later, ?? will
also work with the ordinary syntax (aka #') form, so if the word
“experimental” spooks you, don’t worry about it too much.


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 
For more options, visit

Reply via email to