develooper Front page | perl.perl6.language | Postings from June 2005

Re: AUTLOAD and $_

Thread Previous | Thread Next
From:
Luke Palmer
Date:
June 21, 2005 06:35
Subject:
Re: AUTLOAD and $_
Message ID:
7ca3f0160506210635474d834f@mail.gmail.com
On 6/21/05, Adam Kennedy <cpan@ali.as> wrote:
> You are of course assuming that every use of AUTOLOAD, for all time,
> will result in
> 
> a) Calling another function
> b) An error
> 
> Wouldn't this lead to hacks where people do things like this just to
> prevent perl thinking it's a failure?
> 
> sub AUTOLOAD ($whatever) {  # but no *@_
>       my $s = get_subref_for $whatever;
>       our &::($whatever) := $s;
>       return sub () { 1 };
> }
> 
> The ability to get complete control over the params and context of the
> function, and maybe run something else AFTER the function call is important.

I think people are being pretty closed-minded about closures.  If it
comes down to it, you can always get your good old Perl 5 AUTOLOAD
like this:

    sub AUTOLOAD ($whatever) { sub (*@_) {
        ...
    } }

Luke

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About