Got into attributes today. Damian's Attribute::Handlers really makes this easy. The result so far are the following three modules:
Attribute::TieClasses - attribute wrappers for CPAN Tie classes. The following lines load in Tie::Scalar::Timeout and tie()s $k with those options
use Attribute::TieClasses;
my $k : Timeout(EXPIRES => '+2s');
Attribute::Memoize - Attribute interface to Memoize.pm
use Attribute::Memoize;
sub fib :Memoize {
my $n = shift;
return $n if $n < 2;
fib($n-1) + fib($n-2);
}
Attribute::Abstract - implementing abstract methods with attributes
package SomeObj;
use Attribute::Abstract;
sub new { ... }
sub write : Abstract;
Now, if properties (in Perl 6 jargon) were modifiable at runtime, it would open the door to aspect-oriented programming. There might be a little talk at YAPC::NA and/or YAPC::Europe on that; so far there is a proof-of-concept implementation of aspects using the flexibility afforded by the debugger. More on that later.