Damian Conway wrote:
> 
>    > >        if ( ($num_to_return) = want 'LIST' ) {
>    > >           # do stuff
>    > >        }
>    >
>    > $num_to_return would be zero, but the assignment would cause the
>    > if() to be true.
> 
> A scalar context C<want> would also need to DWIM, presumably by returning
> "0, but true" in that (unusual) situation.

Actually, given Damian's and my conversations last night, it looks like
the first return arg from want() is going to be the context after all
(since then if's and cases's work correctly).

In other words, the code above would return:

   if ( ($context) = want 'LIST' ) {   # 'LIST'
        # do stuff
   }

Which seems redundant until you realize it's needed to make case
statements work:

   switch (want) {
      case 'LIST'   { do_list_stuff }
      case 'SCALAR' { do_scalar_stuff }
   }

And you can now get the number to return by referencing element 1:

   if ( ($num_to_return) = (want 'LIST')[1] ) {   # '3'
        # do stuff
   }

So I think all this taken together solves the "()=" problem implicitly.

-Nate

Reply via email to