> By RFC 21, it looks like the call would be
   > 
   >    if ( want 'LIST' ) {
   >       $num_to_return = want;
   >       # do stuff
   >    }

or, more efficiently:

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

   > However, at one time the discussion had implied that in a scalar
   > context, you could use want as so:
   > 
   >    if ( want eq 'LIST' ) { }

That does not work. If I ever implied it, I plead temporary insanity.


   > That is, it doesn't return the expectant count as arg1, but rather what
   > is wanted. This syntax I actually prefer, since you could easily switch
   > very quickly like so:
   > 
   >     $want = want;
   >     return $want eq 'LIST' ? do_list_stuff :
   >            $want eq 'SCALAR' ? do_scalar_stuff :
   >            ...

In Perl 6 we switch with C<switch>es, mister! ("Muro volente", of course ;-)

        switch (want) {
                case 'LIST'     { do_list_stuff }
                case 'SCALAR'   { do_scalar_stuff }
        }
   
   
   > It also allows you to have a function which
   > automatically is generated or dispatched:
   > 
   >    my $func = lc want . "_func";
   >    return &$func(@_);


The LIST/SCALAR/VOID distinction is always the second value returned
(see the examples in the RFC). So your dispatcher is:

        my $func = lc (want)[1] . "_func";
        return &$func(@_);
   

   > Since RFC 21 is still on v1, my question is: Which is it?

The one you I<don't> like (as usual ;-)

   
   > if in a scalar context want() returned a polymorphic object:

Retro me, Satanas!!!


Damian

Reply via email to