| »»» This post is about the immature Perl 6, not the rock solid Perl 5 ««« |
If Perl6 is to retain scalars; but people write their modules using Ints & Strs etc. for efficiency; then it either forces their users to also use Ints & Strs etc. or multi-subs will have to use runtime resolution.
No. (Or, rather, the user doesn't need to know they're using Ints, Strs, etc.)
multi sub a ( Int $, Int $ ) {} my ($foo, $bar) = 1, 2; say $foo.VAR; says 'Any' say $foo.WHAT; # says '(Int)' a($foo, $bar); # call is resolved at compile time
No type is declared for the container $foo. So it's `of` type defaults to Any. This serves as a constraint on what can be assigned to $foo -- anything that is of type Any or a subtype (anything but Junction or Mu).
The type of the contained value is distinct. In this case the compiler infers that it's an Int. An Int is a subtype of Any so the assignment is OK.
Both of these types are known at compile time.
The type info available at compile-time includes:
Even if the coder calls multisubs without adding type info to their args the call will still be resolved at compile-time if there's enough type info available at compile-time.
»ö« . o O ( "the celebrity tell-all of the Perl-6 cult?" )
In reply to Re^9: rough approximation to pattern matching using local (Multi Subs)
by raiph
in thread rough approximation to pattern matching using local
by gregory-nisbet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |