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

Re: AUTLOAD and $_

Thread Previous | Thread Next
Sam Vilain
June 26, 2005 16:52
Re: AUTLOAD and $_
Message ID:
Piers Cawley wrote:
> For myself, I'd like to see AUTOLOAD with a signature along the lines of:
>    sub AUTOLOAD (Symbol $sym, ArgumentCollection $args, Continuation $cc)
>      returns (Code | Pair)
>    {
>      ...
>    }
> This presupposes a deal of support infrastructure, but also provides
> flexibility. For the 'NullObject' case, you'd simply do C<$cc()> to return
> directly to the caller, skipping over whatever Perl is up to.

That's an excellent suggestion.  After your very enlightening discussion
about continuations in IRC, this popped to mind as an interesting application
for them, along with exception handlers.

This would be great for at least AUTOSUB and AUTOMETH.

However, for AUTOLOAD we're looking for simple Perl 5 alikeness.  And in
Perl 5, the sub name was passed out of band.

So, we need a compromise somewhere, please @cabal.pick:

   - just go for old AUTOLOAD + $AUTOLOAD interface and spit warnings
   - allow topic to refer to variables in lexical scope, but not in @_
     (and pick a good name for $?SUB.called_as)
   - allow generic out-of-band parameters to be passed in
   implies {
       - there needs to be a special subroutine calling method, similar to
         .assuming that lets you do this
       - the method prototype, and specify some way that methods
         defined without a signature can inherit it from somewhere else.
   - declare the topic to be the only out-of-band parameter that does this.
     To avoid it being an accidental global, it would need to be declared with
     "my $_" when used in this manner (of course, other methods like for, given,
     etc that set it have the declaration implicit).
   - scrap complete AUTOLOAD interface compatibility
   - insert solution here ;)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About