Day 6: The Operator’s Curse of Precedence

How the silent hierarchy of operators determines the order in which the universe is constructed.
Published

July 7, 2026

Part of I. A Diurnal Cipher of Raku.

We have mastered the vessels of storage, but we have yet to speak of the dark, unseen forces that govern the assembly of our logic. In the mundane world, this is called “precedence,” but in our journey, it is the Operator’s Curse: a rigid, invisible hierarchy that dictates which runes are invoked first, and which must wait their turn in the void.


The Hierarchy of Rituals

Every operator in Raku is assigned a “precedence” value—a numerical weight that determines its dominance. When an expression contains multiple operators, those with higher precedence consume their surrounding values before those with lower precedence can even stir.

Consider the eternal struggle between addition and multiplication:

say 2 + 3 * 4; # 14
14

To the uninitiated, this might seem ambiguous. But Raku’s architecture mandates that * (multiplication) possesses a higher precedence than + (addition). The multiplication is anchored first, and only then does the addition complete the ritual.


The Weight of the Runic Order

While there are many levels in Raku’s operator hierarchy, three tiers are vital for the survivor to recognize immediately:

Precedence Operators Purpose
Highest . , () Method calls and grouping
Middle * , / Multiplicative actions
Lowest + , - Additive actions

A Warning to the Neophyte: The most powerful tool at your disposal is the parentheses (). Whenever the natural order of precedence threatens to lead your logic into madness, bind your expression in parentheses. It forces the compiler to suspend its hierarchy and obey your command first.


The Assignment Trap

The operator = (assignment) is notoriously weak. It often possesses the lowest precedence of all, ensuring that every other operation within a statement concludes before the final result is bound to a container.

my $x = 1 + 2 * 3;
say $x; # 7
7

Because * is stronger than +, and + is stronger than =, the calculation 1 + (2 * 3) is fully resolved to 7 before the assignment operator ever touches the value.


The Chaining Illusion

Raku contains a unique category of operators that “chain” rather than follow standard precedence rules, specifically for comparisons:

my $n = 5;
say 1 < $n < 10; # True
True

This is not a sequence of two independent checks. Raku views 1 < $n < 10 as a singular, unified statement of truth. It checks the entire range simultaneously, an elegance rarely found in the primitive, C-derived languages of the past.


The Gateway to Complexity

Understanding precedence is the final step in moving from a mere script-writer to an architect of the Language. Without this knowledge, your complex expressions will behave in ways that seem erratic and occult. Once you grasp which operators dominate the others, you can wield them with surgical precision, ensuring the compiler acts exactly as your will dictates.

We have now defined the vessels, the context, the flattening, the aggregation, and the precedence. In our next transmission, we shall finally move beyond simple data and begin to invoke The Multi-Dispatch—the art of defining many destinies for a single name.