In raku documentation for class Slip (https://docs.raku.org/type/Slip) and also in "Lists, sequences, and arrays" documentation (slips section: https://docs.raku.org/language/list), it is stated that "slip", "Slip (method)" and "| (prefix)" can be used to create slips but they behave slightly "different".
The thing is that I've tried to confirm the above statement but with disappointing results.
I run the following tests to find out the differences:
my $l = (1, 2, 3);
say (0, slip($l, 4)).perl;
say (0, ($l, 4).Slip).perl;
say (0, |($l, 4)).perl;
say '------------------------------';
say (slip($l, 4)).perl;
say (($l, 4).Slip).perl;
say (|($l, 4)).perl;
say '------------------------------';
say (0, slip($l)).perl;
say (0, ($l).Slip).perl;
say (0, |($l)).perl;
say '------------------------------';
say (0, slip $l).perl;
say (0, $l.Slip).perl;
say (0, |$l).perl;
say '------------------------------';
say (slip $l).perl;
say ($l.Slip).perl;
say (|$l).perl;
and the results are the same for all three of them:
(0, $(1, 2, 3), 4)
(0, $(1, 2, 3), 4)
(0, $(1, 2, 3), 4)
------------------------------
slip($(1, 2, 3), 4)
slip($(1, 2, 3), 4)
slip($(1, 2, 3), 4)
------------------------------
(0, 1, 2, 3)
(0, 1, 2, 3)
(0, 1, 2, 3)
------------------------------
(0, 1, 2, 3)
(0, 1, 2, 3)
(0, 1, 2, 3)
------------------------------
slip(1, 2, 3)
slip(1, 2, 3)
slip(1, 2, 3)
Is there a catch or is it a documentation bug?
Just a little further down the docs you find an example of the ( a? ) difference:
Please note that prefix:<|> will also apply parameters in a slippy manner to a routine call. It does not forward a Slip to the called routine, that includes return and take.
my \l = gather for 1..10 -> $a, $b { take |($a, $b) }; say l.perl;
# OUTPUT: «((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)).Seq
my \m= gather for 1..10 -> $a, $b { take ($a, $b).Slip }; say m.perl;
# OUTPUT: «(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With