> >         $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?

I think argument ordering would be counterproductive, since one would have tp
either learn (yeah, right!) or continually look-up the order. If there's
any chance of Weird Edge Cases like you posit above, you could write:

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


   > 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.
   > 
   >    @data = Matrix->gendata;         # want 'ARRAY';
   >    ($a, $b, $c) = Matrix->gendata   # fail
   > 
   > It seems like this is something that want should be able to handle.

I *really* doubt that this is ever a useful distinction.
Can anyone suggest a Real World case where it might be useful?

Damian

Reply via email to