Damian wrote:
>       (b) the symmetry of:
>               Logical:                &&      ||      !!
>               Bitwise:                .&      .|      .!
>               Superpositional:         &       |       !
>           is important...mnemonically, DWIMically, and aesthetically.

When I read that this morning I worried - as I do when I read most things
from Damian (but that's a different story).  I think it came down to
what I think was a violation of the Principle of Least Surprise, in the
form of good Huffman coding of operators.

The proposed superpositional operators (& | !) are shorter than the
proposed logical operators (&& || !!).  Normally the shorter
operator (or, in English, word) is the more common one.  Is
superposition really more common than boolean combination?

I sort of toyed with the idea that maybe it should be the logical
operators which are the short ones (& | !) and the rarer superposition
ones that require you to press another key (&& || !!).  This had the
added bonus of leaving logical-not the way we all love, and it probably
had some nostalgia element for both B (*) programmers still out there
with respect to & and |.

But now I see some examples and I'm not so sure.  The size of the
doubled-up operators seem to visually separate the arguments to the
logical operations better.  This is especially so if the precedence for
these operators fall the way people have been saying.

Which looks better?
  if ($a == 1|2|3 || $b eq "x"|"y"|"z")
or
  if ($a == 1||2||3 | $b eq "x"||"y"||"z")
?

Opinions welcomed, but tell us all what typeface you're using.

Besides, maybe superposition is going to turn out to be a very common
thing in Perl after all.  I can guess Damian's response to that.

I think I've already decided that I prefer it the way it is (for recent
values of "is").  I just need some kind soul to pat me on the head and
tell me it's OK.

(Please excuse the Monash staff member, it's been a difficult week.)


(*) The precursor to C, not the highly formal OO language.

-- 
Debbie Pickett http://www.csse.monash.edu.au/~debbiep [EMAIL PROTECTED]
My parents went to a world without bilateral symmetry and all they brought back
                            was this lousy F-shirt.

Reply via email to