http://qs321.pair.com?node_id=277391


in reply to Re^2: USE or Require?
in thread USE or Require?

Why on earth would you want to export new in OO code

I struggled with this one for a while myself, wondering what the idea might be, and I have come to a hypothesis, however shaky. :-) If we want to use a common class framework amongst many classes but dont want them to have a common ISA ancestor then we might make a module like

package ObjectPrototype; use base qw/Exporter/; @EXPORT=qw(new); sub new { my $class=shift; bless {@_},$class }

so now we can say

package Foo; use ObjectPrototype; package Bar; use ObjectPrototype;

without establishing an ISA relationship between any of the module/classes involved.

I admit however that the only reason I could think that this would be useful is if you were doing some funky by hand @ISA tree walking in your code. Having only done this once myself I dont see it being needed much. Although now the thought has come to me... :-)


---
demerphq

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...