Map Index Random Help Topics

## Topic: operator precedence

topics > computer science > programming > Group: expression evaluation

Topic:
notations for brackets

#### Summary

An instruction often includes several function calls. Precedence is used to both distinguish and associate operands with corresponding operators. In language with small numbers of operators, operators are grouped into precedence levels with left to right precedence within each level. Monadic operators are usually of highest precedence followed by arithmetic operators and then relational operators. Bracketing and key words can be used to explicitly indicate precedence.

In languages with a large number of operators, such as APL, precedence levels are dropped, leaving left to right or right to left precedence. An alternative used with natural languages, is spatial precedence which makes A+B of higher precedence than A + B. Left to right spatial precedence can be indicated by A+ .. while right to left by .. +A. (cbb 5/80)

Subtopic: precedence

 Quote: an operation has higher precedence if it distributes over the other, e.g., multiplication and addition [»hoarCA8_1987] QuoteRef: sammJE_1969 ;;441 arithmetic higher precedence than concatenation eg "3"+"2" "5" is "65" QuoteRef: wirtN1_1971 ;;47 precedence done by syntax definition is monadic, multiplying, adding and relational Quote: in Smalltalk, precedence order is unary, binary, keyword, left to right with parentheses [»xlrg8_1981] QuoteRef: rainM1_1973 ;;12 monadic operators occur after the operand

Subtopic: unary operators

 QuoteRef: wileDS11_1973 ;;27 uses key word "none" to resolve ambiguity in two consecutive unary operator definitions, and indicate pre fix operator

Subtopic: parentheses

 Quote: if you have to look up the precedence order, use parentheses to make the order obvious [»maguS_1993]

Subtopic: no precedence

 QuoteRef: mckeWM_1966 ;;111 right to left evaluation cause of large number of operators and prefix operations are right to left. QuoteRef: rainM1_1973 ;;10 precedence in Mary is purely left to right eg a[j,k] if b then *10 else +i-5 fi =: i; this produces optimum code as well QuoteRef: cbb_1973 ;;3/27/74 feeling that precedence should be right to left to =

Subtopic: natural language precedence

 Quote: use tags, punctuation and convention to indicate precedence in natural languages; used in FEA [»postSW7_1978]

Subtopic: spatial precedence

 QuoteRef: cbb_1973 ;;[reading (QuoteRef: sammJE_1969) precedence by spatial grouping eg a*b + c*d or d* b+c QuoteRef: cbb_1973 ;;1/6/80 spatial precedence--needed normal form. A+ .. ... +A is left to right precedence A+B is highest precedence

Related Topics

Topic: notations for brackets
(9 items)

Updated barberCB 10/04