blue leds

richardc on 2001-12-03T18:29:35

After about a month of having to use an external USB keyboard with jay the excellent folks from macimports.com shipped me a replacement in what feels like record breaking time (ordered on Friday, arrived on my desk on the other side of the atlantic at about 2pm Monday)

It's lovely, it's got the control key in the right place, and blue leds! It also means I can get back to hacking in random places, rather than being constrained to a desk.

Right, Perl. Since last london.pm technical meeting I've been constructing my perfect parameter passing idiom in my mind. Now there are quite a few modules for parameter parsing on CPAN, a quick search shows up Class::ParamParser and Params::Validate, but their focus is mainly on validation than the mechanics of passing values.

What I want to be able to do is make this work:

package Class;
use Attribute::Parameters;

sub foo {
     my $self : Parameter;
     my $foo : Parameter 'rw';
     my @bar : Parameter 'optional';

     $foo++;
}

my $val = 1;
Class->foo($val);
print $val; # prints 2
Class->foo(foo => $val);
print $val; # prints 3

Which lands me well and truly in the realms of attributes. Slight catch, currently attributes are dealt with in the CHECK phase, which means the lexicals in the sub can only be monkeyed with once per run.

Luckily[0] Damian has thought of that, and Attribute::Handlers::Prospective should be able to give me access to the RUN phase by trickery[1] before the perl core can do properly but when I last tried it (admittedly at 4am) it didn't want be behave itself.

Given tuits I shall bend this to my will though, and then it'll be just like ada, all over again.

[0] or maybe not, cause otherwise I could have just thrown the towel in.
[1] of the hugely complex sourcefilter variety - shudder