home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / rexx / 1410 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  2.8 KB

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