Non-orthogonality of Perl
When it comes to switching between objects and natives, Perl OO is not quite as orthogonal (or DWIM) as I would like. For instance, assuming I have a class:
package MyArray;
...
sub push { ...}
Then I can treat an instance of that object as an object with a method push, or as a kindof array (kindof, because of course an actual array would have @ for its sigil):
# these are equivalent:
$instance->push(1);
push $instance, 1;
I don't, however, have the orthogonal behaviour with an actual array ref:
# this works:
push @$arrayref, 1;
# this doesn't:
$arrayref->push(1);
# nor, of course, does this:
@$arrayref->push(1);
What I would like is more DWIM than real orthogonality, but if Perl's not DWIM then it's nothing! I guess I'm just wishing for real native array objects like Ruby (sigh).
01:54 PM, 25 Jun 2007 by Mark Aufflick Permalink
bah!
haven't you seen autobox or Moose::Autobox?
by Unregistered Visitor on 06/25/07