PLT 方案:转换“Casting SPELs in LISP”中的宏之一
(defspel game-action (command subj obj place &rest rest)
`(defspel ,command (subject object)
`(cond ((and (eq *location* ',',place)
(eq ',subject ',',subj)
(eq ',object ',',obj)
(have ',',subj))
,@',rest)
(t '(i cant ,',command like that.)))))
这是来自 http://www.lisperati.com/actions.html 的代码 '宏定义宏'。我似乎无法将其适当地转换为方案。有人可以向我解释一下在Scheme中创建同样的东西的过程吗?
(defspel game-action (command subj obj place &rest rest)
`(defspel ,command (subject object)
`(cond ((and (eq *location* ',',place)
(eq ',subject ',',subj)
(eq ',object ',',obj)
(have ',',subj))
,@',rest)
(t '(i cant ,',command like that.)))))
Thats the code from http://www.lisperati.com/actions.html for the 'macro defining macro'. I can't seem to convert it appropriately to scheme. Can someone explain to me the process of creating this same sort of thing in Scheme?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种宏实际上在Scheme中要简单得多,因为您可以使用define-syntax-rule来完成这一切(在标准Scheme代码中,您将需要define-syntax + <代码>语法规则)。你基本上做同样的事情,减去整个引用/取消引用的混乱。
由于这实际上是大部分代码,因此我将整个代码移植到 PLT - 请参阅 在邮件列表上发布。
This kind of macro is actually much simpler in Scheme, since you can do it all with
define-syntax-rule
(in standard Scheme code you will needdefine-syntax
+syntax-rules
). You basically do the same thing, minus the whole quote/unquote mess.And since this is actually most of the code, I ported the whole thing to PLT -- see the post on the mailing list.