home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4388 < prev    next >
Encoding:
Text File  |  1992-11-20  |  2.2 KB  |  65 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!nntp-server.caltech.edu!draco.macsch.com!convex.is.macsch.com!dnl
  3. From: dnl@convex.is.macsch.com (David Lombard)
  4. Subject: Re: Logical operators and operands
  5. Message-ID: <1992Nov20.205801.3839@draco.macsch.com>
  6. Sender: usenet@draco.macsch.com (Usenet Poster)
  7. Organization: MacNeal-Schwendler Corp.
  8. References: <BxwrJC.GME@cs.uiuc.edu> <30476@nntp_server.ems.cdc.com> <30502@nntp_server.ems.cdc.com>
  9. Date: Fri, 20 Nov 92 20:58:01 GMT
  10. Lines: 53
  11.  
  12. In article <30502@nntp_server.ems.cdc.com> mstemper@ems.cdc.com writes:
  13. >
  14. >#pragma opinions ON
  15. >
  16. >This seems dumb! Why shouldn't the operators for equality and
  17. >inequality be the same, no matter what type of operands are
  18. >used? It seems to me that this is poor language design. Can
  19. >somebody come up with a plausible excuse for this? Is it:
  20. > a) Tradition
  21. > b) History
  22. > c) Easier to optimize compilers
  23. > d) Grandfathered in
  24. >
  25. >#pragma opinions OFF
  26. >
  27.  
  28. The *problem* with a comparison such as ( _logical_var_ .eq. .TRUE. )
  29. is that you're obfuscating the meaning of the test.  For example,
  30. would you write ( 1.eq.1 )?  Remember, a logical var _already_ has
  31. a value of .TRUE. or .FALSE., an expression such as A.EQ.B is
  32. creating a logical value (i.e., .TRUE. or .FALSE.).  Don't these
  33. comparisons look a little bizarre to you?
  34.  
  35.     IF( LOGVAR.EQ..TRUE. ) ...
  36.     IF( LOGVAR.NE..TRUE. ) ...
  37.     IF( LOGVAR.EQ..FALSE. ) ...
  38.     IF( LOGVAR.NE..FALSE. ) ...
  39.     IF( .NOT.LOGVAR.EQ..TRUE. ) ...
  40.     IF( .NOT.LOGVAR.NE..TRUE. ) ...
  41.     IF( .NOT.LOGVAR.EQ..FALSE. ) ...
  42.     IF( .NOT.LOGVAR.NE..FALSE. ) ...
  43.     IF( LOGVAR.EQ..NOT..TRUE. ) ...
  44.     IF( LOGVAR.NE..NOT..TRUE. ) ...
  45.     IF( LOGVAR.EQ..NOT..FALSE. ) ...
  46.     IF( LOGVAR.NE..NOT..FALSE. ) ...
  47.     IF( .NOT.LOGVAR.EQ..NOT..TRUE. ) ...
  48.     IF( .NOT.LOGVAR.NE..NOT..TRUE. ) ...
  49.     IF( .NOT.LOGVAR.EQ..NOT..FALSE. ) ...
  50.     IF( .NOT.LOGVAR.NE..NOT..FALSE. ) ...
  51.  
  52. Aren't the following just a tad cleaner?
  53.  
  54.     IF( LOGVAR ) ...
  55.     IF( .NOT.LOGVAR ) ...
  56.  
  57. Regards,
  58. DNL
  59.  
  60.                  MY_COMMENTS = MY_OPINIONS = NOBODY_ELSES;
  61.  
  62. David N. Lombard    The first thing we do,         The MacNeal-Schwendler Corp
  63. dnl@macsch.com      Let's kill all the lawyers.    815 Colorado Blvd
  64. (213) 259-4911      II Henry VI, IV.ii             Los Angeles, CA  90041
  65.