~> Skeleton
infix ~>
~>The rules for ~> have not been written yet. Everything below is extracted rather than authored: the official documentation supplies the classification, and the interpreters were asked directly about the rest.
What is established #
Classification #
~> is parsed as an infix at the multiplicative precedence level, left-associative.
That is level 7 of 27 on the ladder, counting from the tightest. Operators sharing a level bind equally; grouping among them is decided by associativity alone.
Shares its precedence level with #
*, /, div, %, %%, mod, +&, +<, +>, ~&, ~<, ?&, gcd, lcm.
These all bind equally tightly, so an expression mixing them groups by associativity alone.
What the interpreter said #
Raku++ parses this spelling. Asked to compile:
my $a = 6; my $b = 3; sink($a ~> $b)
…it got through the parser. On its own that establishes very little: it says nothing about whether the construct executes, let alone whether the result is right. Where the behaviour table below exists, that is the stronger evidence — those expressions were actually run.
Covered upstream #
The official documentation has a section for this construct: docs.raku.org. Until the rules here are written, that is the better reference.
Observed behaviour #
Each expression below was executed by both interpreters when this page was built; the results are recorded, not written. The operands are chosen to cross the boundaries that catch people out: string against number, a list where a scalar was meant, a boolean, an undefined value, and an exact rational.
Raku++ and Rakudo agree on every row below.
| Expression | Raku++ | Rakudo |
|---|---|---|
1 ~> 2 | rejected by both — Cannot resolve caller infix:<~>>(Int, Int); no such operator is defined | |
"a" ~> "b" | rejected by both — Cannot resolve caller infix:<~>>(Str, Str); no such operator is defined | |
1 ~> "2" | rejected by both — Cannot resolve caller infix:<~>>(Int, Str); no such operator is defined | |
(1, 2) ~> (3, 4, 5) | rejected by both — Cannot resolve caller infix:<~>>(List, List); no such operator is defined | |
True ~> False | rejected by both — Cannot resolve caller infix:<~>>(Bool, Bool); no such operator is defined | |
Nil ~> 1 | rejected by both — Cannot resolve caller infix:<~>>(Nil, Int); no such operator is defined | |
1/2 ~> 1/3 | rejected by both — Cannot resolve caller infix:<~>>(Rat, Int); no such operator is defined | |