Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re^2: USE or Require?

by demerphq (Chancellor)
on Jul 24, 2003 at 01:20 UTC ( #277391=note: print w/replies, xml ) Need Help??


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...

Replies are listed 'Best First'.
Re^4: USE or Require?
by adrianh (Chancellor) on Jul 24, 2003 at 09:01 UTC

    I can't see how it would be very useful since none of the other methods in ObjectPrototype would be available to Foo and Bar :-)

      Well you could have a grab bag of useful methods and approaches all in a single module, and mix and pick as you like. Wheras if you did it via ISA its all or none.


      ---
      demerphq

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277391]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-01-28 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?