Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site digi-g.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!stolaf!umn-cs!digi-g!brian
From: brian@digi-g.UUCP (Merlyn Leroy )
Newsgroups: net.lang.c
Subject: No more logical XOR
Message-ID: <412@digi-g.UUCP>
Date: Tue, 27-Nov-84 11:55:04 EST
Article-I.D.: digi-g.412
Posted: Tue Nov 27 11:55:04 1984
Date-Received: Fri, 30-Nov-84 08:07:44 EST
Distribution: net
Organization: Digigraphic Systems Corp., Mpls, MN
Lines: 38



OK, since hardly anybody seemed to like my idea of logical XOR (^^),
and wanted me to use !a!=!b instead of a^^b, I have another proposal;
replace all operators with NAND ops!  This new operator ($ for bitwise,
$$ for logical) can replace nearly everything, vis;

a & b  -->  (a $ b) $ (a $ b)
a | b  -->  (a $ a) $ (b $ b)
a ^ b  -->  ((a $ a) $ b) $ (a $ (b $ b))
~a     -->  (a $ a)
a && b -->  (a $$ b) $$ (a $$ b)
a || b -->  (a $$ a) $$ (b $$ b)
a ^^ b -->  ((a $$ a) $$ b) $$ (a $$ (b $$ b))	[I never give up]
!a     -->  (a $$ a)
a == b -->  (((a $ a) $ b) $ (a $ (b $ b))) $$ (((a $ a) $ b) $ (a $ (b $ b)))
a != b -->  ((a $ b) $ ((a $ a) $ (b $ b))) $$ ((a $ b) $ ((a $ a) $ (b $ b)))
e?a:b  -->  (((e $$ e)-1) $ a) $ ((((e $$ e) $$ (e $$ e))-1) $ b)

(the last three operators don't work with floats, but REAL programmers don't
need floats)

Now we can get rid of those extra operators, like & | ^ ~ && || ! == != and ?:
and replace them with one (well, two) simple operators.  Ideally, this would be
implemented on a computer built entirely of NOR gates.

Notice how this simplifies expressions:
if (!a || (b == c))
	becomes:
if (((a $$ a) $$ (a $$ a)) $$
    ((((b $ b) $ c) $ (b $ (c $ c))) $$ (((b $ b) $ c) $ (b $ (c $ c))) $$
     (((b $ b) $ c) $ (b $ (c $ c))) $$ (((b $ b) $ c) $ (b $ (c $ c)))))

Next week:  Replacing +-*/%++ with --

							Merlyn Leroy

P.S.  The ":-)" operator can be replaced by ((:$-) $$ (: $ :) $ (-$$-))