It's approaching the middle of November, and here in Gloucester it's started to get really quite cold.
But, you know, I'm not bitter by any stretch. It's a million times warmer than it was when I was living in Scotland (really a million - try living there if you don't believe me). I think today will be the last day of "just a t-shirt" for a while though. It was just too cold. I would have only gotten away with a t-shirt up until september in scotland though.
Appologies to all scots. I'm sure some parts of your country are lovely (well, some parts are), but your weather sucks, and Livingston was just nasty.
Oh, and perl's OO is broken...
picture this:
package Base;
my %FEATURES = (a => 1, b => 0, c => 1);
sub features {
my @features;
foreach (keys %FEATURES) {
push @features, $_ if $FEATURES{$_};
}
return @features;
}
1;
and a sub-class:
package SubClass;
use base 'Base';
my %FEATURES = (a => 0, b => 1, c => 1);
1;
Now query SubClass->features(), and you get ('a', 'c').
This is covered somewhere in Damian's book, I recall, but it's a gotcha that people used to true OO should watch out for.
The way to fix it is to make the FEATURES hash into a method call that returns a hash. This way, when you call the base features() method, and it looks up the FEATURES hash, it gets the inherited method, and thus the right set of FEATURES.
I'm sure this will be fixed in Perl 6, otherwise I'll be around to kick Damian's butt ;-)
Re:Not Broken
pudge on 2001-11-09T18:05:53
Just to further show how this is not anything "broken" in Perl, consider:package main;
my %FEATURES = (a => 1, b => 0, c => 1);
print Base->features;
package Base;
sub features {
my @features;
foreach (keys %FEATURES) {
push @features, $_ if $FEATURES{$_};
}
return @features;
}
1;It returns ('a', 'c'), even though the variable is declared in main
... because the data is not declared in any package at all, really. Also, classes can be split between several files and scopes, and the lexical data in one scope will not be available in any other. Re:Not Broken
Matts on 2001-11-10T16:03:42
Fine, it's a missing feature then.
It's still annoying, and something that would "work" in other OO languages, without using the data-as-sub work around.
Re:Try Class::Data::Inheritable
Matts on 2001-11-10T16:01:22
It would have *exactly* the same results if I'd used "our".Re:Try Class::Data::Inheritable
autarch on 2001-11-10T17:11:16
I know that!
My point was that you shouldn't even _expect_ it to work with 'my'. With 'our' (or a global) you might think that it _should_ work (though it wouldn't).
I was basically saying that even though pudge was right, he was missing your main point, which was simply that Perl should have inheritable class attributes.
-daveRe:Try Class::Data::Inheritable
pudge on 2001-11-12T17:01:28
I wasn't missing that point; in fact, I specifically enunciated it.:-)