Reserved Operators and Precedence
This lists all the multi-character "punctuation" operators. Note that ... is not an operator.
The operators are sequenced from highest to lowest evaluation priority. Operators grouped together have the same priority. In parenthesis is shown whether an operator appears in front of a value (prefix) or between values (infix). Some operators can be used in both contexts. It also specifies the symbolic name of any method associated with that operator.
Value operators
- ' '
- (p) symbol literal
- " "
- (p) text literal
- yield
- (p) yield expression
- ( )
- (p) prioritizes expression to be evaluated as a group
- [ ] *[ ] +[ ]
- (p) variable declaration
- { }
- (p) code block
Term operators
- + new
- (p 'new') new instance
- .
- (i) method call/property access
- .:
- (i) property access
- ::
- (i '[]') indexed access
- ( )
- (i) method call parameters
- [ ]
- (i '[]') indexed access
Prefix operators
- -
- (p '@-') negate
- @
- (p) Internet resource load
- <<
- (p '<<') append to 'this'
- >>
- (p '>>') prepend to 'this'
Arithmetic/Collection operators
- **
- (i '**') exponent
- *
- (i '*') multiply
- /
- (i '/') divide/split
- %
- (i '%') remainder
- +
- (i '+') add/concatenate
- -
- (i '-') subtract
Range operator
- ..
- (i) creates a range
Evaluation operators
- ==
- (i '<=>') equal
- !=
- (i '<=>') not equal
- ===
- (i) equivalent
- ~~
- (i '~~') match
- <=>
- (i '<=>') compare (rocketship)
- <
- (i '<=>') less than
- <=
- (i '<=>') less than or equal
- >
- (i '<=>') greater than
- >=
- (i '<=>') greater than or equal
Evaluation operators
- ! not
- (p) logical not
- && and
- (i) logical and
- || or
- (i) logical or
Ternary operator
- ? else
- (i) "if .. then .. else ..." expression
Append/Prepend operators
- <<
- (i '<<') append
- >>
- (i '>>') prepend
Assignment operators
Note: Within variable declarations, the evaluation priority of ',' and '=' are reversed.
- ,
- (i) value separation
- =
- (i) assign
- :
- (i) 'this' property assign
- :=
- (i) '[]' 'this' index set
- +=
- (i '+') add in place
- -=
- (i '-') subtract in place
- *=
- (i '*') multiply in place
- /=
- (i '/') divide in place
Async operator
- ^ async
- (p) create asynchronous thread
Line terminator
The semicolon ; is the lowest priority "operator".
Reserved Names
Name tokens are typically used for variables or properties. However, certain names are reserved for special meaning within an Acorn program:
- and
- logical 'and' operator used in boolean expressions
- async
- asynchronous operator
- baseurl
- url of the program's source code
- break
- terminate a loop block
- context
- The value of the currently executing execution state
- continue
- Re-iterate a 'while' or 'for' block
- do
- A block that performs an automatic '.begin' and '.end'
- each
- The block for iterating over a collection of values
- else
- A clause within an 'if' statement
- elif
- A clause within an 'if' statement
- false
- The value of 'false'
- if
- A conditional block or clause
- in
- A clause within a 'each' block
- into
- A clause within a 'match/with' block
- local
- ensures variable(s) are treated as locally scoped
- match
- Matches a calculated value to several possible values
- new
- Creates a new instance
- null
- The value of 'null'
- not
- logical 'not' operator used in boolean expressions
- or
- logical 'or' operator used in boolean expressions
- return
- terminate execution of a method with a return value
- self
- references the method's self parameter value
- selfmethod
- the currently executing method or closure
- this
- The value of the most inclusive 'with' block
- true
- The value of 'true'
- using
- clause on this block
- wait
- A block that waits until all its execution contexts are done.
- while
- A repetitive block or clause
- with
- A clause in a 'match' block
- yield
- suspend a generator with a return value