trait is default
Documentation for trait
is default assembled from the following types:
multi sub trait_mod:<is>(Routine , :!)
There is a special trait for
is default. This trait is designed as a way to disambiguate
multi calls that would normally throw an error because the compiler would not know which one to use. This means that given the following two
Routines, the one with the
is default trait will be called.
multi sub f() is defaultmulti sub f()f(); # OUTPUT: «"Hello there"␤»
is default trait can become very useful for debugging and other uses but keep in mind that it will only resolve an ambiguous dispatch between two
Routines of the same precedence. If one of the
Routines is narrower than another, then that one will be called. For example:
multi sub f() is defaultmulti sub f(:)f(); # "Use of uninitialized value $greet..."
In this example, the
is default was called because it was actually narrower than the
Sub with it.