In Raku functions documentation, there is an example as follows:
enum DebugType <LOG WARNING ERROR>;
#|[ Prints a message to stderr with a color-coded key. ]
proto debug(DebugType:D $type, Str:D $message --> Bool:_) {
note sprintf qb/\e[1;%dm[%s]\e[0m %s/, {*}, $type.key, $message
}
multi debug(LOG;; Str:D --> 32) { }
multi debug(WARNING;; Str:D --> 33) { }
multi debug(ERROR;; Str:D --> 31) { }
I am trying to figurue out the usage of double semicolons after LOG
, WARNING
, and ERROR
, and can only find it in Raku Signatures documentation. Under subtitle 'Long names', it's said that:
"To exclude certain parameters from being considered in multiple dispatch, separate them with a double semicolon." And its example code is:
multi sub f(Int $i, Str $s;; :$b) { say "$i, $s, {$b.raku}" };
f(10, 'answer');
# OUTPUT: «10, answer, Any»
But in the above multi debug subs, why do we have to exclude their first argument from being considered in multiple dispatch? Once they are excluded, how could Raku know which debug sub to dispatch? I tried to replace each double semicolon with a 'normal' single comma, but could not find anything different in the output. Besides, the f
sub example makes me puzzled. There's only one multi sub there. How double semicolon affect its dispatch? The subtitle 'Long names' is weird, too. Thanks a lot in advance for any kind explanation.