Have we considered how nicely this would play with scalar attributes? One could imagine appropriate Attribute::Handlers hanging their data off arbitrary scalars. Then one could imagine:
sub UNIVERSAL::property {
require Magic::Attach;
my $self = shift;
my $property_name = shift;
return Magic::Attached::attached($self, $property_name);
}
sub UNIVERSAL::but {
require Magic::Attach;
my $self = shift;
my($property_name, $value) =@_;
Magic::Attach::attach($self, $property_name, $value);
}
and the like.
The fun begins when you start to try and implement Perl6ish tricks along the lines of return $value->but('true') or (possibly nicer) return $value :but('true'); . For this to work really well you would need have 'but' dispatch to appropriate handlers in some way (possibly through a registry system), but it's not beyond the wit of man...
Can you tell I've been thinking along these lines for a while but have lacked the appropriate tuits? |