Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Besides making this possible (and guaranteeing I won't get into namespace entanglements with superclass members), I really like the idea of genuine encapsulation in perl. Etc. "Inside out". That is freaking brilliant. Somebody deserves a prize for that one.

On behalf of the many people who have worked on refining the idea of inside-out classes, we're extremely glad you're so pleased. And, yes, we actually did get a prize: the ability to do clean encapsulated OO in Perl. ;-)

BTW, if you like the idea of inside-out objects, you're going to love the framework we've build to make them easier to use: Object::InsideOut. Using that framework, your above solution could be written like this:

{ package test; use Object::InsideOut; use IO::Socket::INET; my @socket :Field Handles(IO::Socket::INET) :Default( _make_socket() ); my @field :Field Arg(field) Get(getField); sub _make_socket :Private { return IO::Socket::INET->new( PeerAddr => '127.0.0.1:80', Proto => 'tcp', Blocking => 0 ); } sub _cleanup :Destroy { my $self = shift; print STDERR "Bye from $field[$$self]!\n"; } } my $obj = test->new(field => "okay"); print $obj->getField."\n"; print $obj->sockhost."\n"; my $two = test->new(field => "two"); print $two->getField."\n";

I would encourage you to take a look at the module. It may quite literally turn your world inside-out.

Damian

In reply to Re^3: Inherit from IO::Handle derived class by DamianConway
in thread Inherit from IO::Handle derived class by halfcountplus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-23 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found