miller/docs6/docs/reference-dsl-operators.md
John Kerl abe061e408
Flags lookup-table and doc autogen (#655)
* Tableize flag-parsing for on-line help, doc autogen, etc.

* Rename cli,cliutil packages -> climain,cli

* stub for new flag-list page

* Fix alignment & formatting for webdoc/manpage autogen

* per-flag-section info in mlr help

* Fix comparison of actual vs expected stderr file in regtest

* Replace old flag-parser with new
2021-09-08 22:16:40 -04:00

2.8 KiB

# DSL operators

Operator precedence

Operators are listed in order of decreasing precedence, highest first.

Operators              Associativity
---------              -------------
()                     left to right
**                     right to left
! ~ unary+ unary- &    right to left
binary* / // %         left to right
binary+ binary- .      left to right
<< >> >>>              left to right
&                      left to right
^                      left to right
|                      left to right
< <= > >=              left to right
== != =~ !=~           left to right
???
??
&&                     left to right
^^                     left to right
||                     left to right
? :                    right to left
=                      N/A for Miller (there is no $a=$b=$c)

Operator and function semantics

  • Functions are often pass-throughs straight to the system-standard Go libraries.

  • The min and max functions are different from other multi-argument functions which return null if any of their inputs are null: for min and max, by contrast, if one argument is absent-null, the other is returned. Empty-null loses min or max against numeric or boolean; empty-null is less than any other string.

  • Symmetrically with respect to the bitwise OR, XOR, and AND operators |, &, and ^, Miller has logical operators ||, &&, and ^^.

  • The exponentiation operator ** is familiar from many languages, except that an integer raised to an int power is int, not float.

  • The regex-match and regex-not-match operators =~ and !=~ are similar to those in Ruby and Perl.