With a little patch to Attribute::Handlers I've hacked together Attribute::Typed, which is based on the
my Dog $spot
I was inspired to look for this example by this message from Ian Phillipps, as I've been looking to find out how to get at the class type information in lexicals at run time for a while now (not with that much diligence mind you).
It turns out its pretty simple. Simply use attributes! Hopefully shortly you should be able to do:
my Canine $spot : typed = Dog->new();
and have it perform runtime type checking, with respect to the classes. So it will allow $spot to be set to anything that is either undef, or blessed and isa( Canine ). Anyway, I've sent a patch to Attribute::Handlers to the honorable Mr. Conway, and if accepted, Attribute-Types should be winging its way to the CPAN RSN.