From 8a4af211c346fd00ded0bb1b1384ca1514ed84e0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 12 Jun 2008 13:45:04 +0000 Subject: 25149: add C_PRECEDENCES option to make arithmetic have C/Perl precedence --- Doc/Zsh/arith.yo | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'Doc/Zsh/arith.yo') diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo index d7f1ae608..423e6c1bc 100644 --- a/Doc/Zsh/arith.yo +++ b/Doc/Zsh/arith.yo @@ -91,8 +91,8 @@ taken for a parameter name. cindex(arithmetic operators) cindex(operators, arithmetic) -An arithmetic expression uses nearly the same syntax, precedence, and -associativity of expressions in C. +An arithmetic expression uses nearly the same syntax and +associativity of expressions as in C. The following operators are supported (listed in decreasing order of precedence): @@ -119,6 +119,29 @@ short-circuiting, and only one of the latter two expressions in a ternary operator is evaluated. Note the precedence of the bitwise AND, OR, and XOR operators. +With the option tt(C_PRECEDENCES) the precedences (but no other +properties) of the operators are altered to be the same as those in +most other languages that support the relevant operators: + +startsitem() +sitem(tt(PLUS() - ! ~ PLUS()PLUS() --))(unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement) +sitem(tt(**))(exponentiation) +sitem(tt(* / %))(multiplication, division, modulus (remainder)) +sitem(tt(PLUS() -))(addition, subtraction) +sitem(tt(<< >>))(bitwise shift left, right) +sitem(tt(< > <= >=))(comparison) +sitem(tt(== !=))(equality and inequality) +sitem(tt(&))(bitwise AND) +sitem(tt(^))(bitwise XOR) +sitem(tt(|))(bitwise OR) +sitem(tt(&&))(logical AND) +sitem(tt(^^))(logical XOR) +sitem(tt(||))(logical OR) +sitem(tt(? :))(ternary operator) +sitem(tt(= PLUS()= -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= **=))(assignment) +sitem(tt(,))(comma operator) +endsitem() + cindex(mathematical functions, use of) cindex(functions, math, use of) Mathematical functions can be called with the syntax -- cgit 1.4.1