ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
AUTLOAD and $_
by Sam Vilain other posts by this author
Jun 19 2005 9:21PM messages near this date
Re: proposal: 404 method | Re: AUTLOAD and $_
From S10;

   In any case, there is no longer any magical $AUTOLOAD variable. The
   name being declared or defined can be found in $_ instead. The name
   does not include the package name. You can always get your own package
   name with $?PACKAGENAME.

So, what is the prototype of AUTOLOAD?  It is clearly called from the
relevant (package dispatcher & type & perl5_compat(stash) ) object, but
how?

  sub AUTOLOAD($_ = $CALLER::$_, *@_) {
      ...
  }

In a way, $_ forms part of the prototype definition, but is "out of band"
to the regular arguments on @_; it can't interfere with positional
characteristics, or you have to "shift" it off before you goto the right
sub.

OK, we could play tricks with localization of variables, but in the face
of continuations and coroutines, localization falls apart.  This is fine
for people writing `ordinary´ code (perhaps), but for a core language
feature it should be resolved IMHO.

Out-of-band arguments seem to have been a hot topic in the past;

    http://xrl.us/ggt7 - Long (50+ posts) thread

    http://xrl.us/ggua - suggestion from Damian;

      $foo = sub { print $_ } is given($_);

I actually quite like that syntax, or at least the idea of using a trait
of some kind to specify non-positional arguments.  It keeps them well
out of the way of `safe´ programming conventions :).

In fact, it has to do wierder things than just accept it out of band to
parameters - ideally it would not also interfere with another sub that
uses $CALLER::_.

Perhaps to avoid that mess, the AUTOLOAD function is simply expected to
call &func.goto if it wants all the effects of the presence of the
AUTOLOAD sub to go away.  Assuming that the prototype is re-checked on a
goto, to ensure that type guarantees specified in the function signature
are honoured, then the necessary side effects should just happen.

Sam.
Thread:
Sam Vilain
Juerd
Sam Vilain
Maxim Sloyko
Juerd
Adam Kennedy
Juerd
Luke Palmer
Chromatic
Juerd
Chromatic
Juerd
Luke Palmer
John Macdonald
Chromatic
Juerd
Rod Adams
Larry Wall
Rod Adams
Chromatic
Juerd
Sam Vilain
Sam Vilain
Juerd

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved