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.

Replies are listed 'Best First'.
Re: Re: Re^4: Private method variations
by jdporter (Paladin) 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.

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();