Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

james (1129)

  (email not shown publicly)


Journal of james (1129)

Wednesday September 05, 2001
09:00 AM


[ #760 ]

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:

use Attribute::Typed;

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.