Luke Palmer wrote:

Not that that couldn't be done with a closure anyway...

    {
      my Class %valClasses;

sub Val($N) returns Class {
my Class $rclass = %valClasses{$N} //= class {
multi *isa ($obj, $rclass $class) { $obj ~~ $N }
} }
}


multi factorial (Int & Val(0) $g) { 1 }

I don't think so. I seriously doubt you can put a run-time-evaluated sub call in a type specification <visions of Dan fainting in horror> ;-)
A C<macro> might do the trick though.


Oh, and I was wrong to originally write: C<multi *isa ...>
Multimethods live in their own namespace. No * required.

Damian



Reply via email to