home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!imc
- From: imc@comlab.ox.ac.uk (Ian Collier)
- Newsgroups: comp.lang.rexx
- Subject: Re: Spelt logical operators
- Message-ID: <2902.imc@uk.ac.ox.prg>
- Date: 15 Dec 92 14:26:55 GMT
- References: <1garqeINNdt4@oak9.doc.ic.ac.uk>
- Organization: Oxford University Computing Laboratory
- Lines: 47
- X-Local-Date: Tuesday, 15th December 1992 at 2:26pm GMT
- Originator: imc@msc8.comlab
-
- In article <1garqeINNdt4@oak9.doc.ic.ac.uk>, ppch@doc.ic.ac.uk (P P C Herring) wrote:
- >Has anyone ever suggested that Rexx implement the logical operators in words as
- >well as in symbols?
-
- >I mean: if not A or (B and C) then ...
- >as an alternative to: if \A | (B & C) then ...
- >which suffers from using characters that keyboard manufacturers and operating
- >systems treat as fair game for their own purposes, and also from not being very
- >close to any of the notations used in logic (except for '&').
-
- The | is commonly used for "or" (I don't know why): it means bitwise-or in
- C, and is often used in syntax diagrams between alternative choices. It
- also means "or" in the Unix utility "egrep".
-
- The "not" symbol was originally a "fallen L" which is the mathematical
- symbol for that operator. This is character 5F in EBCDIC (on CMS, where
- REXX was originally developed). The first PC versions of REXX used ^ for
- the "not" operator, because EBCDIC 5F is commonly translated to that
- character when downloading into ASCII. However I'm not sure why "\" has been
- chosen for the standard "not" operator.
-
- >Of course there is the problem of reserved words, but surely this is a case for
- >saying that code using 'and' to mean something other than '&' is just bad style.
-
- Firstly, notice that on the right-hand side of an assignment there are no
- reserved words whatsoever. Using words for arithmetic or logic operators
- goes against this. Secondly, you may think it is bad style to have a
- variable named "and", but there will surely be some programs out there that
- get broken. Consider that some programmers will name their variables in
- languages other than English. A French game program in which you have to
- collect gold pieces might have a variable called "or" (think about it...)
-
- >It would also be possible to implement xor and nand, and also the material
- >conditional if a suitable abbreviation can be found
-
- xor already exists: && (admittedly ths isn't very intuitive!). nand isn't
- that hard to do, really, is it? \(A & B).
-
- Finally, why stop at the logical operators? The symbols % and // are not
- very intuitive are they? Better have a word for ** as well, just to be on
- the safe side. Oh, and if we are to have a word for not, we have to have a
- word for \== too. Etc, etc...
-
- No, I think we are much better off with just symbols. :-)
-
- Ian Collier
- Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk
-