R6RS方案的make-variable-transformer有什么好处?
在查看 R6RS 中的 syntax-case
部分时,我看到了关键字 make-variable-transformer
,它被描述为标识符宏。 给出的例子非常少,我并没有理解为什么它是必要的,或者什么用例需要它。 事实证明,找到其使用的更多示例也很困难。 据推测,它使得某种形式的语法转换成为可能,或者更优雅?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阅读 http:// www.r6rs.org/final/html/r6rs-lib/r6rs-lib-ZH-13.html#node_sec_12.3 我的看法如下:
如果
mac
是语法转换器(mac foo (bar baz))
会将整个 s-expr 替换为转换结果,这可能会导致任何内容如(SOMETHING)
,而( foo mac bar)
将仅替换mac
,从而生成(foo SOMETHING bar)
。通常
(set!mac 'foo)
会发出错误信号,似乎转换器不能出现在集合表达式的左侧,但如果mac
是变量转换器< code>(set!mac 'foo) 会使用整个 s-expr 来调用mac
。我的直觉告诉我,如果您开始使用宏实现数据类型,这将很有用。
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 onlymac
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 ifmac
is a variable transformer(set! mac 'foo)
would instead callmac
with the whole s-expr.My intuition tells me this would be useful if you start implementing datatypes with macros.
我在寻找有关 make-variable-transformer 的文档时遇到了这个问题。 这是我遇到的一个问题,建议使用 make-variable-transformer ...
http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/96b07d431f1a66de/777f8e07ae1855f3#777f8e07ae1855f3
杰克交易
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