Pregunta

My question is in a comment in the following code.

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 ) ]>
    }
}

This code sample is from: Infix format for Nemerle macro

¿Fue útil?

Solución

These numbers determine operator precedence and associativity. If the first number is smaller, the operator is left-associative, if the second — right. Operators with larger numbers have higher precedence. It looks unintuitive at first sight, but when you think more about the details of expression parsing, it makes quite a bit of sense.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top