Great changes, Damian! I'm just going to check on some clarification:

> When C<want> is called with arguments in a scalar context:
> 
>         $primary_context = want 'LIST', 2, 'LVALUE';

So these arguments can be passed in any order, and want checks them? I
like it. But I worry if you say something like:

   my 42 @stuff = get_data;

And get_data looks like:

   sub get_data {
       # Need to make sure we're being asked for 42 return
       # values in an array context
       (want 'LIST', 42) ? return @hugedata 
                         : die "Bad usage of get_data";
   }

You might not get what you want? Admittedly, the above is an edge case,
but I wonder if some argument ordering is needed?

> =item 'LIST'
> 
> The subroutine was called in a list context:
> 
>         @vals = func();
>         print func();

> =item 'HASH'
> 
> The subroutine was called in a context where its return value is
> assigned to a hash:
> 
>         %hash = func();

I've been thinking about this for some time, but haven't had a chance to
bring it up. It seems that we should really be detecting an 'ARRAY'
context as well, if we are detecting a 'HASH' context, since a 'LIST' is
really just a more general case of both of them.

It seems to me a script could check for a 'LIST' and return something
which users could then assign to an array or an enumerated list as well,
similar to wantarray. For example:

   @user = getpwnam('nwiger');
   ($name, $pass, ... $shell) = getpwnam('nwiger');

Both of these are ok, and "want 'LIST'" works fine. However, sometimes
you don't want just a 'LIST' context, but want to make sure it's an
array:

   @data = Matrix->gendata;         # want 'ARRAY';
   ($a, $b, $c) = Matrix->gendata   # fail

It seems like this is something that want should be able to handle.
Input?

-Nate

Reply via email to