我似乎无法弄清楚如何将 'when' 关键字添加到 BOO ,它应该表现为 '如果'。 我想我可以制定一个方法,但是我无法像使用 if 那样移动 when 。 任何指示将不胜感激。
-标记
I cannot seem to figure out how I can add the 'when' keyword to BOO which should behave as an 'if'. I figure I could make a method, but then I cannot move the when around like I can with if. Any pointers would be appreciated.
-Mark
这将满足您的要求:
import Boo.Lang.Compiler.Ast import Boo.Lang.Compiler.MetaProgramming macro when: return [| if $(when.Arguments[0]): $(when.Block) |] x = 1 when x == 1: print "x equals one" when x == 2: print "x equals two"
顺便说一句,请随时(也)在 Boo 邮件列表上提问,以便更快地获得(更多)答案;)
http://groups.google.com/group/boolang/
This would do what you want:
Btw, feel free to (also) ask on the Boo mailing-list to get (more) answers quicker ;)
这将是宏的工作。 从您链接到的页面来看,Boo 似乎有语法宏。
顺便说一句,为什么您需要现有功能的精确副本?
This would be a job for a macro. From the page you linked to, it seems that Boo has syntactic macros.
As an aside note, why do you need an exact duplicate of an existing functionality?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
这将满足您的要求:
顺便说一句,请随时(也)在 Boo 邮件列表上提问,以便更快地获得(更多)答案;)
http://groups.google.com/group/boolang/
This would do what you want:
Btw, feel free to (also) ask on the Boo mailing-list to get (more) answers quicker ;)
http://groups.google.com/group/boolang/
这将是宏的工作。 从您链接到的页面来看,Boo 似乎有语法宏。
顺便说一句,为什么您需要现有功能的精确副本?
This would be a job for a macro. From the page you linked to, it seems that Boo has syntactic macros.
As an aside note, why do you need an exact duplicate of an existing functionality?