Skip to content
📖 Auto vs Modern CBook contents

Chapter 4: Expressions ​

Level 1 — Acquaintance

How C and Auto compose values through operators and evaluation.

Expressions are the workhorses of any program. Every computation — from adding two numbers to deciding which branch to take — ultimately reduces to evaluating an expression. C offers a rich set of operators; Auto keeps the same power but packages it in a safer, more readable form.


4.1 Operands and Operators ​

An operand is a value that an operator acts upon. An operator specifies what to do with its operand(s). C classifies operators by how many operands they take:

ArityC exampleMeaning
Unary-xNegation
Binarya + bAddition
Ternarya ? b : cConditional choice

Auto uses the same classification but replaces the ternary ?: with an if/else expression syntax. The operator table below maps the most common C operators to their Auto equivalents.

CategoryC operatorAuto equivalentNotes
Arithmetic+ - * / %+ - * / %Identical
Increment/Decr.++ --x = x + 1No side-effect operators
Compound assign+= -= *=x = x + yExplicit assignment
Comparison== != < > <= >=== != < > <= >=Identical
Logical&& || !and or notWord forms in Auto
Ternarya ? b : cif a { b } else { c }Expression form
Bitwise& | ^ ~ << >>same operatorsAvailable in both

Takeaway: Auto removes operators that modify objects in-place (++, --, +=) and replaces them with plain assignment. This makes every expression's effect explicit.

Released under the MIT License.