Larry Wall wrote:

>     $a .! $b  # bitwise xor
>     $a ! $b   # logical xor
>     ! $b      # logical not
> 
> I like the notion that binary ! means that the two sides are sharing
> one "not".  That's the definition of XOR in a nutshell.

I like that too.  It also means that C<!!> and C<.!!> become the
equivalence operators for free.  (Technically inverting the right
operand then doing xor, but that's ... um, equivalent.)

However it means that the binary ops become:

  $a || $b  # logical or
  $a .| $b  # bitwise or
  $a && $b  # logical and
  $a .& $b  # bitwise and
  $a ! $b  # logical xor
  $a .! $b  # bitwise xor

That makes logical xor look a little inconsistent (it doesn't line up
for a start).

Doubling the exclamation mark would make logical xor fit in better
(though that'd leave three of them in equivalence).

> I also like the idea that ~ is entirely freed up for some other
> nefarious use.

Yeah; how'd that happen?  Seems like not too long ago we were short of
punctuation symbols, and now you've got a spare one lying around.

Smylers

Reply via email to