简体   繁体   English

boo中可重用的嵌套宏?

[英]Reusable nested macro in boo?

I am writing a DSL using boo and I would like to keep it as DRY as possible. 我正在使用boo编写DSL,并且我希望将其保持为DRY。 I was wondering if there is any way to reuse nested macro. 我想知道是否有任何方法可以重用嵌套宏。 Eg in 例如

topmacro1:
    submacro:
        topmacro1['submacro'] = 'defined'

topmacro2:
    submacro:
        topmacro2['submacro'] = 'defined'

The submacro macro just sets a value in the parent macro's hash. submacro宏仅在父宏的哈希中设置一个值。 Is there any way to avoid redefining submacro in every parrent macro? 有什么方法可以避免在每个父宏中重新定义子宏?

Thanks in advance, 提前致谢,

Thomas 汤玛士

I think the best you can do is to break out the body of the submacro into a function and simply call that function. 我认为您最好的办法是将子submacro的主体分解为一个函数,然后简单地调用该函数。 That should be DRY enough. 那应该足够干。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM