boo 中可重用的嵌套宏?
我正在使用 boo 编写 DSL,我希望使其尽可能保持干燥。我想知道是否有任何方法可以重用嵌套宏。例如,在
topmacro1:
submacro:
topmacro1['submacro'] = 'defined'
topmacro2:
submacro:
topmacro2['submacro'] = 'defined'
子宏中宏只是在父宏的哈希中设置一个值。有没有办法避免在每个父宏中重新定义子宏?
提前致谢,
托马斯
I am writing a DSL using boo and I would like to keep it as DRY as possible. I was wondering if there is any way to reuse nested macro. E.g. in
topmacro1:
submacro:
topmacro1['submacro'] = 'defined'
topmacro2:
submacro:
topmacro2['submacro'] = 'defined'
The submacro macro just sets a value in the parent macro's hash. Is there any way to avoid redefining submacro in every parrent macro?
Thanks in advance,
Thomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您能做的最好的事情就是将子宏的主体分解为一个函数并简单地调用该函数。那应该足够干了。
I think the best you can do is to break out the body of the
submacro
into a function and simply call that function. That should be DRY enough.