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 ]

richardc (1662)

  (email not shown publicly)

Journal of richardc (1662)

Monday December 03, 2001
01:29 PM

blue leds

[ #1476 ]
After about a month of having to use an external USB keyboard with jay the excellent folks from 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 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';


my $val = 1;
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