The way I see that happening is if we allow certain kinds of constants
in multi declarations.
my multi whatever ($self, Class $context is derived(Scalar):
$arg1, $arg2) {...}
That'd be nice in a number of different ways. Without this special
feature, an enabling level of indirection can be added with
parameterized types:
my class ClassVal [Class $TYPE] {
# Does nothing, and may even be optimized away
}
my multi whatever ($self, ClassVal[Scalar] $context:
$arg1, $arg2) {...}
# ...
whatever($_, ClassVal[want], $arg1, $arg2);
# ^ does a : go here?
That doesn't handle inheritance correctly, but it can be made to,
provided proper introspection into $TYPE.
Luke
method whatever($arg1, $arg2)
{ my multi whatever ($self, Scalar $context:
$arg1, $arg2) { ... }
my multi whatever ($self, Array $context:
$arg1, $arg2) { ... }
whatever($_, want(), $arg1, $arg2) }
Just wondering.