Begin main content

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 | Short Link | Comments (3)

XML

Blog Categories

software (27)
..cocoa (13)
  ..heads up 'tunes (5)
..ruby (4)
..lisp (1)
..perl (3)
..openacs (1)
mac (18)
embedded (2)
..microprocessor (2)
  ..avr (1)
electronics (3)
design (1)
photography (24)
..black and white (6)
..A day in Sydney (18)
..The Daily Shoot (5)
food (2)

Notifications

Icon of Envelope Request notifications

Syndication Feed

XML

Recent Comments

  1. Unregistered Visitor: To replace current categories or remove them...
  2. Unregistered Visitor: Base 256
  3. Unregistered Visitor: ...
  4. Unregistered Visitor: www.pipl.com
  5. Unregistered Visitor: This reminds me of the infinite monkeys
  6. Unregistered Visitor: Feedback
  7. Unregistered Visitor: Diito... Snow Leopard no worky
  8. Unregistered Visitor: WFM
  9. Unregistered Visitor: Pie
  10. Unregistered Visitor: Helpful