develooper Front page | | Postings from September 2000

Re: logical ops on arrays and hashes

Thread Next
Jeremy Howard
September 12, 2000 13:51
Re: logical ops on arrays and hashes
Message ID:
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):

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About