evolving

Friday 30th May, 2003

You know, I could reconstruct the last week from random commitlogs and stuff, but why don't you just do that yourself - I'll still be here when you get back.

Yes that's right, Class::DBI happened to Siesta. It's great that it did, but I can't help but feel like I gave birth.

Had an idea for a new itch scratcher while eating bagels, and then forgot it afterwards. Happily it came back during a lull at the office, so here she blows:

 package Foo;
 use Class::Final;
 sub frobnicate : final {
     my $self = shift;
     ...
 }
 
 package Bar;
 use base 'Foo';
 
 sub frobnicate {
     my $self = shift;
     ...
 }

Now as close to compile time as possible, that should explode a bit like this:

 Attempt to override final method Foo->frobnicate in subclass Bar, line 666

The idea came to me in a spell of the-horse-has-bolted thinking. Just a few days before while doing some Class::DBI stuff I declared a method called get. As some of you might know, Class::DBI depends on many many things, and inherits from a bunch of those, one of which is Class::Accessor. Class::Accessor holds get in special regard, and so when I accidentally overrode it all the magic came flying out of the sides without me noticing.

Of course for that I probably want something more like virtual methods, only less invasise. I picture a scheme whereby you could declare the methods you'd advise caution in overriding, and then when overriding you'd have a way to declare that you were paying the correct amount of attention, a little like this:

 package Foo;
 use Class::Mumble;
 sub frobnicate : dress_up_warm {
     my $self = shift;
     ...
 }
 
 package Bar;
 use base 'Foo';
 
 sub frobnicate : ok_mum {
     my $self = shift;
     ...
 }

Apart from I'm not even close to having the right set of keywords to use as decoration.

The good part is at least I know how to write it, the hard part will be in not melting during the random good weather.