@@ -499,4 +499,56 @@ except that C<temp> does not reset the value).
499
499
Hypothetical reset: if the current scope is exited either through an exception
500
500
or C < fail() > , the old value is restored.
501
501
502
+ = head1 Nonchaining Binary Precedence
503
+
504
+ = head2 infix does
505
+
506
+ sub infix:<does>(Mu $obj, Mu $role)
507
+
508
+ Mixes C < $role > into C < $obj > at run time. Requires C < $obj > to be mutable.
509
+
510
+ C < $role > doesn't need to a be a role, it can be something that knows how
511
+ to act like a role, for example enum values.
512
+
513
+ = head2 infix but
514
+
515
+ sub infix:<but>(Mu $obj, Mu $role)
516
+
517
+ Creates a copy of C < $obj > with C < $role > mixed in. Since C < $obj > is not
518
+ modified, C < but > can be used to created immutable values with mixins.
519
+
520
+ C < $role > doesn't need to a be a role, it can be something that knows how
521
+ to act like a role, for example enum values.
522
+
523
+ = head2 infix cmp
524
+
525
+ multi sub infix:<cmp>($a, $b) returns Order:D
526
+
527
+ Generic, "smart" three-way comparator.
528
+
529
+ Compares strings with string semantics, numbers
530
+ with number semantics, L < Pair > objects first by key and then by value etc.
531
+
532
+ if C < $a eqv $b > , then C < $a cmp $b > always returns C < Order::Same > .
533
+
534
+ say (a => 3) cmp (a => 4); # Increase
535
+ say 4 cmp 4.0; # Same
536
+ say 'b' cmp 'a'; # Decrease
537
+
538
+ = head2 infix leg
539
+
540
+ multi sub infix:<leg>($a, $b) returns Order:D
541
+
542
+ String three-way comparator.
543
+
544
+ Coerces both arguments to L < Str > , and then does a lexicographic comparison.
545
+
546
+ = head2 infix <=>
547
+
548
+ multi sub infix:«<=>»($a, $b) returns Order:D
549
+
550
+ Numeric three-way comparator.
551
+
552
+ Coerces both arguments to L < Real > , and then does a numeric comparison.
553
+
502
554
= end pod
0 commit comments