{*} reports that the correct candidate will call the runtime.
Instead of forcing you to write {{*}} for the normal case, simply invoking the correct one, the compiler allows you to shorten it to {*}
This is true for all proto routines, such as sub , method , regex , token and rule .
For prototype regex , only bare {*} allowed.
The main reason is probably because someone really didn’t have a good way to make him work reasonably in a regular expression sublanguage.
So here is a proto sub example that does some things that are common to all candidates.
#! /usr/bin/env perl6 use v6.c; for @*ARGS { $_ = '--stdin' when '-' } # find out the number of bytes proto sub MAIN (|) { try { # {*} calls the correct multi # then we get the number of elems from its result # and try to say it say {*}.elems # <------------- } # if {*} returns a Failure note the error message to $*ERR or note $!.message; } #| the number of bytes on the clipboard multi sub MAIN () { xclip } #| the number of bytes in a file multi sub MAIN ( Str $filename ){ $filename.IO.slurp(:!chomp,:bin) } #| the number of bytes from stdin multi sub MAIN ( Bool :stdin($)! ){ $*IN.slurp-rest(:bin) } sub xclip () { run( «xclip -o», :out ) .out.slurp-rest( :bin, :close ); }
source share