我的问题在下面代码中的注释中。
namespace TestMacroLib
{
[assembly: Nemerle.Internal.OperatorAttribute ("TestMacroLib", "multiply", false, 160, 161)]
// what does 160 and 161 represent? The parameters are "left" and "right", but that doesn't help.
public macro multiply(op1, op2)
{
<[ ( $op1 * $op2 ) ]>
}
}此代码示例来自:Infix format for Nemerle macro
发布于 2013-09-30 20:04:29
这些数字决定了算子的优先级和结合性。如果第一个数字较小,则运算符是左结合的,如果是第二个右的.数字较大的运算符具有更高的优先级。乍一看,这似乎是不直观的,但当您更多地考虑表达式解析的细节时,它就有了相当大的意义。
https://stackoverflow.com/questions/19084300
复制相似问题