开发者

Reusable nested macro in boo?

开发者 https://www.devze.com 2023-01-29 12:48 出处:网络
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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消