Luke Palmer <[EMAIL PROTECTED]> writes:

> On 6/20/05, chromatic <[EMAIL PROTECTED]> wrote:
>> On Mon, 2005-06-20 at 12:11 +0200, Juerd wrote:
>> 
>> > I think there exists an even simpler way to avoid any mess involved.
>> > Instead of letting AUTOLOAD receive and pass on arguments, and instead
>> > of letting AUTOLOAD call the loaded sub, why not have AUTOLOAD do its
>> > thing, and then have *perl* call the sub?
>> 
>> Who says AUTOLOAD will always either call a loaded sub or fail?
>
> Uh, what else can it do?  It doesn't have to load a sub to return a
> code reference.

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.

'ArgumentCollection'? Well, that's the activation record and I'd like to see it
allowing methods like:

    my ($foo, $bar, $baz) =
      $args.parse_signature('Int $foo, String $bar, Code $baz')

 That way code could probe the argument structure in order to do its own
 dispatch.

 As for returning a coderef or a pair. If you return a coderef, Perl simply
 calls it and throws it away. Returning a pair, with a name (long or short) as
 the key and the code as the value would make perl bind the code to the given
 name (which should be compatible with the name passed in in the first place).

 Details left as an exercise for the interested reader.

Reply via email to