Nathan Torkington wrote:
> 
> Actually, the only refinement I'd like to see is that boolean operators
> (==, &&, ||) be excepted from the distributive rule.
> 
> This is to permit:
> 
>   if (@a == @b)         # shallow comparison
> 
> and
> 
>   @a = @b || @c;        # @a=@b or @a=@c;       # ish

Yeah, I agree completely with this sentiment. This is far more useful to
me than having them element-wise.

My main fear is that while this RFC seems really good for math ops, but
seems too array- and PDL-specific. Here are some examples of mixed
contexts; how would these be handled under the RFC?

    @user_data = @empty || $user;
    %files = scalar(get_files()) || @DEFAULT;
    $total = @items + $MIN_VALUE;
    @full_names = @first_names . "Smith";

What I'd like to see is Perl to really DWIM (especially in that last
one). But to do so you have to redo the rules of the RFC:

    Op Type         Default homogenous context     Mixed context
    --------------- ------------------------------
-------------------------- 
    Math ops        element-wise                   forced to scalar
    Boolean ops     whole entity                   forced to list 
    String ops      element-wise                   forced to list

With these rules, the above examples now work as I'd expect (or at least
want) them to:

    @user_data = @empty || $user;             # @user_data =
($user);            
    %files = scalar(get_files()) || @DEFAULT; # %files =
(@DEFAULT);          
    $total = @items + $MIN_VALUE;             # $total = 5 + 2;
    @full_names = @first_names . "Smith";     # @full_names = ("Bob
Smith", "Jim Smith");

True, this opens a whole other can of worms, but I think it's closer to
what people would want to use the ops for, and it's also more usable to
us non-PDLers. Note there's a lot of inherent want()-like behavior built
in there.

-Nate

Reply via email to