Skip to content

Instantly share code, notes, and snippets.

@Qqwy
Created July 7, 2016 20:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qqwy/3066910db6bf9adcf91b8c5e99148c85 to your computer and use it in GitHub Desktop.
Save Qqwy/3066910db6bf9adcf91b8c5e99148c85 to your computer and use it in GitHub Desktop.
Elixir Operator Info
# See https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L52
# for the list of operators with associativity, etc.
# The operators in this list are grouped by precedence, low to high.
# The comments indicate the operator's normal function, as well as its ability to be defined/overridden.
-> # CompileError 'unhandled operator'. only allowed in anonymous function syntax.
& # CompileError, only allowed in short anonymous function syntax.
<- # Free to implement, but used in `for` comprehensions.
\\ # Free to implement, but used as 'default parameter' syntax.
when # unable to define, as used to separate guard clauses.
:: # used for Typespecs. Cannot override as it conflicts with Elixir special forms.
| # Free to implement, but used as 'cons' inside lists/maps.
=> # Only allowed in maps. Cannot override as it conflicts with Elixir special forms.
= # Match operator. Cannot override as it conflicts with Elixir special forms.
|| # Part of stdlib: short-cirtuiting truthyish OR
||| # Part of Bitwise: bitwise OR
or # Guard-safe short-circuiting boolean OR
&& # Part of stdlib: short-cirtuiting truthyish AND
&&& # Part of Bitwise: bitwise AND
and # Guard-safe short-circuiting boolean AND
== # Part of stdlib: Equality
!= # Part of stdlib: Inequality
=~ # Part of stdlib: String-to-Regexp matching
=== # Part of stdlib: Strict Equality (difference floats vs ints)
!== # Part of stdlib: Strict Inequality (difference floats vs ints)
< # Part of stdlib: Less than
> # Part of stdlib: Greater than
<= # Part of stdlib: Less than or equal to
>= # Part of stdlib: Greater than or equal to
|> # Part of stdlib: Pipe operator. (pass lhs as first argument into rhs)
>>> # Part of Bitwise: Right Bitshift
<<< # Part of Bitwise: Left Bitshift
~>> # Free and definable!
<<~ # Free and definable!
~> # Free and definable!
<~ # Free and definable!
<~> # Free and definable!
<|> # Free and definable!
in # Part of stdlib: check if lhs is a member of rhs. Guard-safe when rhs is range or list
^^^ # Part of Bitwise: Binary XOR
++ # Part of stdlib: List append
-- # Part of stdlib: List difference (removes at most one occurence)
.. # Part of stdlib: inline syntax for ranges.
<> # Part of stdlib: Binary concatenation.
+ # Part of stdlib: Arithmetic addition
- # Part of stdlib: Arithmetic subtraction
* # Part of stdlib: Arithmetic multiplication
/ # Part of stdlib: Arithmetic division
# All operators below are unary operators.
+ # Part of stdlib: Arithmetic unary plus
- # Part of stdlib: Arithmetic unary negation
! # Part of stdlib: truthyish NOT
^ # Part of stdlib: 'pin' operator that prevents rebinding.
not # Part of stdlib: guard-safe boolean NOT
~~~ # Part of Bitwise: binary NOT
. # Cannot override, as compiler attempts to interpret `.` during function definition.
@ # Part of stdlib: Read/write module attributes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment