Search code examples
fortranoperatorsoperator-precedence

Fortran user defined operators precedence rules


The built-in operators of Fortran have well-defined precedence rules. What about user-defined operators? I understand that user-defined binary operators have a lower priority than every built-in operator, as explicitly indicated here. Is it possible to modify such behavior? And is it possible to establish user-defined precedence between user-defined operators? Or do we have only the wise use of parentheses to control the order of operations?


Solution

  • I explain ALL of this in https://stevelionel.com/drfortran/2021/04/03/doctor-fortran-in-order-order/

    Briefly, user-defined unary (one operand) operators have the highest precedence, user-defined binary operators (two operands) have the lowest precedence. You cannot adjust operator precedence.