On Thu, Mar 10, 2011 at 11:31:38AM +0100, Johan Vromans wrote:
> Okay, here's my 0.02 cents...
>
> http://www.squirrel.nl/pub/xfer/Struct.pm
+1
I like it. It's small simple useful. Most importantly, its name doesn't
include the word "object" or "class". This immediately jumps out as
being useful in all those little cases where in Perl I get upset about
the lack of C's struct types and begrudgingly use a hash instead,
potential for key typoes and all.
my $point = { x => 100, y => 200 };
say "Point is at " . $point->{x};
Or sometimes I 'use constant' up a set of index constants, and use those
instead. They're much less friendly on the eye though.
use constant { POINT_X => 0, POINT_Y => 1 };
my $point = [ 100, 200 ];
say "Point is at " . $point->[POINT_X];
Nowhere in this world does there need to exist any of the machinery of
being an object. OO is a very powerful hammer, but not every "I want a
little tiny composite value type" problem is a nail.
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
Thread Previous
|
Thread Next