tags:

views:

176

answers:

2

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?

+2  A: 

After 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.

JBF
+1  A: 

I came across this searching for documentation on make-variable-transformer. Here's a problem I had that make-variable-transformer was suggested for...

http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/96b07d431f1a66de/777f8e07ae1855f3#777f8e07ae1855f3

Jack Trades