2

What's the difference between

MACRO foo BLOCK
...
END

and

BLOCK foo
...
END

?

Historically I've always used the latter but have come to a new shop where they seem to have always used the former, and was wondering what the difference was.

4

1 回答 1

2

块实际上是一个MACRO函数,每次调用时都会重新计算,并且传递的任何变量都是宏的本地变量。命名块要么是静态的,要么是通过PROCESSor调用INCLUDE的,其中关于变量范围的常见警告适用。

例如

MACRO foo (arg1, arg2) BLOCK;
    ... do something with arg1 and arg2
END;

...

Foo is a [% foo(bar,baz) %]

相对

BLOCK foo
    ... do something with arg1 and arg2
END;

...

Foo is a [% PROCESS foo arg1=bar arg2=baz %]

长话短说,MACRO语法不那么冗长,特别是对于看起来和行为像函数调用的代码。

在精美的手册中有很好的记录

于 2013-10-31T06:09:33.047 回答