in reply to Re: Re: Lexical::Alias & subroutines
in thread Lexical::Alias & subroutines

Lexical::Alias 0.04 will be coming to CPAN shortly. Two tiny changes -- a $SWAP global you can set to 1 if you want to send the arguments to the functions in the reversed order you specified, and a note about the 5.8.0 bug.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Re: Re: Lexical::Alias & subroutines
by Jenda (Abbot) on May 19, 2003 at 15:14 UTC

    I don't think the $SWAP global is the right implementation. It's too global :-)

    What about having

    alias $original => $alias;
    and
    Alias $alias => $original;
    or something like this. Or at least the SWAPing should be on package level. IHMO of course.

    Thanks, Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature

      That's what local is for, no?

      Makeshifts last the longest.

        Definitely no. If I did

        sub foo { local $SWAP = 1; alias $alias => $original; ... Module::bar(some,params); ... }
        and someone else in the Module writes
        sub bar { alias $original => $alias; ... }
        And suddenly his/her code starts trying to do something else than it should. Just because it was called from my foo() instead of directly. The local() could only "help" if I used it like this:
        sub foo { {local $SWAP = 1;alias $alias => $original;} ... }
        But that's to long. I'd need the $SWAP to be lexical to my whole file, not local to the current call/block stack.

        I think the nicest solution is alias $original => $alias; and Alias $alias => $original;.

        Or maybe I should just learn it's the other way around versus what I'd expect :-)

        Jenda
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
           -- Rick Osborne

        Edit by castaway: Closed small tag in signature