Skip to content
📖 The Auto Programming LanguageBook contents

Appendix B: Operator Table ​

This appendix provides a comprehensive reference for every operator in Auto, organized by precedence from highest to lowest. When multiple operators appear in the same expression, Auto evaluates them according to this ordering.

Precedence Summary ​

Operators with higher precedence bind more tightly. Within the same group, most operators are left-associative unless noted otherwise.

PrecedenceCategoryOperators
1 (highest)Unary prefix- ! * view mut ~
2Multiplicative* / %
3Additive+ -
4Comparison< > <= >=
5Equality== != is
6Logical AND&& (alias: and)
7Logical OR|| (alias: or)
8Null coalescing??
9Range.. ..=
10Assignment= += -= *= /= %=
11Pipe|>
12 (lowest)Error propagationpostfix ! postfix ?

Detailed Tables ​

1. Unary Prefix Operators ​

These operators appear before their operand. They have the highest precedence.

OperatorDescriptionExampleRustPythonCTypeScriptChapter
-Numeric negation-x-x-x-x-x2
!Boolean NOT!flag!flagnot flag!flag!flag2
*Dereference (raw pointer)*ptr*ptrN/A*ptrN/A11
viewBorrow as read-only referenceview s&sN/Aconst T*readonly11
mutBorrow as mutable referencemut s&mut sN/AT*N/A11
~Async blueprint (type modifier)~Stringimpl FutureAwaitableN/APromise16

2. Multiplicative Operators ​

Standard arithmetic for multiplication, division, and remainder. Left-associative.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
*Multiplication6 * 7426 * 76 * 76 * 76 * 72
/Integer division15 / 4315 / 415 // 415 / 4Math.trunc(15/4)2
%Remainder (modulo)17 % 5217 % 517 % 517 % 517 % 52

Division of two int values truncates toward zero. If either operand is float, the result is float.

3. Additive Operators ​

Addition and subtraction. Left-associative. The + operator also concatenates strings.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
+Addition / concatenation5 + 385 + 35 + 35 + 35 + 32
-Subtraction10 - 4610 - 410 - 410 - 410 - 42

4. Comparison Operators ​

These operators compare two values and return a bool. They work on numbers, strings (lexicographic), and booleans.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
<Less than10 < 20true10 < 2010 < 2010 < 2010 < 202
>Greater than10 > 20false10 > 2010 > 2010 > 2010 > 202
<=Less than or equal10 <= 10true10 <= 1010 <= 1010 <= 1010 <= 102
>=Greater than or equal10 >= 20false10 >= 2010 >= 2010 >= 2010 >= 202

5. Equality Operators ​

Equality checks and type tests.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
==Equal to10 == 20false10 == 2010 == 2010 == 2010 === 202
!=Not equal to10 != 20true10 != 2010 != 2010 != 2010 !== 202
isType check / pattern matchx is intboolmatches!isinstance()N/Atypeof / instanceof7, 17

The is operator checks whether a value matches a type or pattern. In control flow, it triggers smart casts that narrow the type within the branch (see [Chapter 17][ch17]).

6. Logical AND ​

Short-circuit evaluation: if the left side is false, the right side is not evaluated.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
&&Logical AND (symbolic)true && falsefalsetrue && falseN/Aa && ba && b2
andLogical AND (keyword)true and falsefalseN/Aa and bN/AN/A2

Both forms are interchangeable. The a2p transpiler converts && to and for Python.

7. Logical OR ​

Short-circuit evaluation: if the left side is true, the right side is not evaluated.

OperatorDescriptionExampleResultRustPythonCTypeScriptChapter
||Logical OR (symbolic)true || falsetruetrue || falseN/Aa || ba || b2
orLogical OR (keyword)true or falsetrueN/Aa or bN/AN/A2

Both forms are interchangeable. The a2p transpiler converts || to or for Python.

8. Null Coalescing ​

OperatorDescriptionExampleRustPythonCTypeScriptChapter
??Default value for ?Tname ?? "unknown".unwrap_or("unknown")name or "unknown"N/Aname ?? "unknown"9

The ?? operator returns the left side if it is Some(value), otherwise it returns the right side as the default. It only applies to ?T (optional) values.

9. Range Operators ​

Used in for loops and to create range expressions.

OperatorDescriptionExampleValuesRustPythonCTypeScriptChapter
..Exclusive end range0..50, 1, 2, 3, 40..5range(0, 5)for (i=0;i<5;i++)N/A3
..=Inclusive end range1..=51, 2, 3, 4, 51..=5range(1, 6)for (i=1;i<=5;i++)N/A3

The .. range is exclusive on the right (does not include the upper bound). The ..= range is inclusive on the right (includes the upper bound).

10. Assignment Operators ​

Assignment is a statement in Auto, not an expression. It does not return a value.

OperatorDescriptionExampleEquivalentRustPythonCTypeScriptChapter
=Assignx = 5--x = 5x = 5x = 5x = 52
+=Add and assignx += 3x = x + 3x += 3x += 3x += 3x += 32
-=Subtract and assignx -= 2x = x - 2x -= 2x -= 2x -= 2x -= 22
*=Multiply and assignx *= 4x = x * 4x *= 4x *= 4x *= 4x *= 42
/=Divide and assignx /= 2x = x / 2x /= 2x //= 2x /= 2x /= 22
%=Remainder and assignx %= 3x = x % 3x %= 3x %= 3x %= 3x %= 32

11. Pipe Operator ​

OperatorDescriptionExampleRustPythonCTypeScriptChapter
|>Forward pipedata |> transform |> saveMethod chainingMethod chainingN/AMethod chaining19

The pipe operator feeds the left side as the first argument to the function on the right. It enables a data-flow style where transformations are read left to right. This is equivalent to method chaining (data.transform().save()), but works with standalone functions.

12. Error Propagation Operators ​

These postfix operators handle ?T (optional) and !T (result) types. They have the lowest precedence because they apply to the entire preceding expression.

OperatorDescriptionExampleRustPythonCTypeScriptChapter
postfix !Unwrap !T; panic on Errparse(s)!.unwrap()N/AN/A! (non-null assert)9
postfix ?Propagate error / unwrap !Tread_file(path)?? (same)N/AN/AN/A9

The postfix ! unwraps a !T value, returning the Ok payload or panicking with the Err message. It is similar to Rust's .unwrap().

The postfix ? propagates errors up the call stack. Inside a function marked with ! in its return type, expr? unwraps the result on success or returns the error to the caller. It is equivalent to Rust's ? operator.

Type Modifier Operators ​

These operators appear in type positions rather than expression positions. They modify the meaning of a type annotation.

ModifierDescriptionExampleRust EquivalentChapter
?TOptional (nullable) valuefn find(id int) ?UserOption<T>9
!TResult (fallible) valuefn read(path str) !strResult<T, String>9
~TAsync blueprint (future)fn fetch(url str) ~strimpl Future<Output=T>16

These can be composed: ~?String is a future optional string, and ~!int is a future fallible integer.

Access Operators ​

These operators are used for member access and optional chaining. They are not listed in the precedence table because they are postfix accessors with inherent precedence (left to right, tightly binding).

OperatorDescriptionExampleRustPythonCTypeScriptChapter
.Field / method accessuser.nameuser.nameuser.nameuser.nameuser.name8
?.Optional chainingaddr?.city.as_ref()?.cityN/AN/Aaddr?.city9
.awaitAwait async blueprintfetch().await.awaitawaitN/Aawait16

Notes ​

  • Short-circuit evaluation: && and || evaluate the right side only if necessary. If the left side of && is false, the right side is skipped. If the left side of || is true, the right side is skipped.
  • No operator overloading: Auto does not support user-defined operator overloading. All operators have fixed semantics defined by the language.
  • Integer division: Dividing two int values with / truncates toward zero. Use at least one float operand for decimal division.
  • Assignment is not an expression: Unlike C, assignment in Auto does not return a value. You cannot write x = y = 5 or use assignment inside an if condition.
  • Keyword aliases: and and or are aliases for && and ||. They exist primarily for readability and for the Python transpiler, which maps them directly.

Released under the MIT License.