While looking at the syntax-case
section in R6RS, I saw the keyword make-variable-transformer
, described as an identifier macro. The example given is very minimal, and I am not groking why it is necessary, or what use-cases require it. Finding additional examples of its use is also proving difficult. Presumably it makes some form of syntax transformation possible, or more elegant?
views:
176answers:
2After reading http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-13.html#node_sec_12.3 my take is as follows:
If mac
is a syntax transformer
(mac foo (bar baz))
would replace the entire s-expr with the result of the transformation this could result in anything say (SOMETHING)
, while (foo mac bar)
would replace only mac
resulting in (foo SOMETHING bar)
.
Normally (set! mac 'foo)
would signal an error it seems that the transformer can not appear on the left of a set expression, but if mac
is a variable transformer (set! mac 'foo)
would instead call mac
with the whole s-expr.
My intuition tells me this would be useful if you start implementing datatypes with macros.
I came across this searching for documentation on make-variable-transformer. Here's a problem I had that make-variable-transformer was suggested for...
Jack Trades