Ingo Blechschmidt wrote:
How do I have to annotate the type specification in the
declaration of the subroutine to not include the class Foo, but
only allow instances of Foo?
My understanding is that Foo.does(Foo) is false and sub params
are checked with .does(). This automatically excludes class args.
That is you have to explicitly order them:
sub blarb (Foo|Class[Foo] $foo, $arg) # or with CLASS[Foo] ?
...; # Do something with instance or class $foo
Foo|Class[Foo] is a supertype of Foo and Class[Foo] and as
such allows its subtypes Foo and the Class[Foo] parametric
role instanciation. Note that Foo|Class allows calls like
blarb( Int, "HaHa" ).
Actually I'm not convinced that class Foo should automatically
constitute a (proper) type other than Any. But since .does falls
back to .isa it comes out the same since the only way here to get
a Foo doer is by instanciating the class Foo.
TSa (Thomas Sandlaß)