develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: logical ops on arrays and hashes

Thread Next
From:
Jeremy Howard
Date:
September 12, 2000 13:51
Subject:
Re: logical ops on arrays and hashes
Message ID:
002b01c01cfb$d8c370f0$c1252ccb@SAMANTHA
Dan Sugalski wrote:
> ...would anyone object to the _binary_ operators being used
> instead? They don't have short-circuit semantics, and generally don't have
> any reasonable meanings for hashes and arrays. With that, instead of
> writing the above code, you'd write:
>
>    @a = @b | @c;
>
> nothing short-circuits but then you don't expect it to, and that's more or
> less OK. The and operation would likely return the left-hand value if both
> are true, and xor would return whichever of the two were true, or undef of
> both (or neither) were true.
>
Of course they have reasonable meanings for arrays--element-wise operations
(RFC 82):

  http://tmtowtdi.perl.org/rfc/82.html

Any operation you can do on a scalar you should be able to do element-wise
on a list, and certainly it's not hard to come up with situations where this
is useful for non-short-circuiting bitwise operators. Bit vectors and
associated masks may well be stored in lists, for instance.

This discussion should probably be on -data, BTW.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About