Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re^4: Private method variations

by TimToady (Parson)
on Mar 02, 2004 at 00:36 UTC ( #333122=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Private method variations
in thread Private method variations

Well, package _ will probably be the current package, just as $_ is the current topic and &_ is the current sub. Also, in some cases, @_ is still the current argument list, and %_ will often be the current options.


Comment on Re: Re^4: Private method variations
Select or Download Code
Re^6: Private method variations
by adrianh (Chancellor) on Mar 02, 2004 at 01:16 UTC
    Well, package _ will probably be the current package

    Phoey :-)

    Ah well. Now leaning toward one of:

    $self->OUR::private_method $self->__::private_method $self->_MY::private_method

    All screams of "Good grief that's too ugly for words" welcome!

Re^6: Private method variations
by adrianh (Chancellor) on Mar 02, 2004 at 14:00 UTC

    Here's a thought - offload the naming decision onto the developer:

    package Foo; use Package::Prefix Our => 'Foo::Our'; sub new { my $self = bless {}, shift; $self->Our::init(@_); return $self; }; sub Our::init { ... };

    which would have the affect of defining/calling Foo::Our::init. This could have other convenient uses:

    use Package::Prefix VLPN => 'Very::Long::Package::Name'; use VLPN::Foo; use VLPN::Bar; my $foo = VLPN::Foo->new(); my $bar = VLPN::Bar->new();
Re: Re: Re^4: Private method variations
by jdporter (Canon) on Mar 03, 2004 at 20:41 UTC
    &_ is the current sub? Cool! That means I can recurse, tail-eliminatively, with
    goto &_
    rather than
    goto &{ (caller(0))[3] };
    Well, I view it as a significant bene, anyway.

    But then, you probably have better things in mind for TRE...

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-11-29 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls