home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / ada / 3889 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!olivea!sgigate!sgi!wdl1!wdl39!mab
  2. From: mab@wdl39.wdl.loral.com (Mark A Biggar)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Mixing logical operators
  5. Message-ID: <1993Jan5.231518.17527@wdl.loral.com>
  6. Date: 5 Jan 93 23:15:18 GMT
  7. References: <1993Jan5.180216.7426@fcom.cc.utah.edu>
  8. Sender: news@wdl.loral.com
  9. Organization: Loral Western Development Labs
  10. Lines: 29
  11.  
  12. In article <1993Jan5.180216.7426@fcom.cc.utah.edu> swillden@news.ccutah.edu (Shawn Willden) writes:
  13. >My copy of the Ada standard (ANSI/MIL-STD-1815A) says in 4.5.4:
  14. >    ...for a sequence of operators of the same precedence level,
  15. >    the operators are associated in textual order from left to
  16. >    right...
  17. >which indicates to me that 
  18. >      if i=5 and j=2 or k=3 then
  19. >      ...
  20. >should be interpreted as 
  21. >       if (i=5 and j=2) or k=3 then
  22. >but the VAX Ada compiler complains that logical operators cannot be
  23. >intermixed.
  24. >Is the VAX compiler wrong?  Am I reading the appropriate part of the 
  25. >standard?
  26.  
  27. No, it is implisit in the LRM that even though "and", "or" and "xor" 
  28. are at the same precedence level they DON'T associate with each other.
  29. The grammar given in LRM section 4.4 disallows expressions with mixed logical 
  30. operators. Para 4 section 4.5 only states associativity rules of operators at 
  31. precedence levels below that of the logical operators.  The previous sentence 
  32. to the one you quoted limits the scope of the paragraph to only subexpressions
  33. from relations on down and excludes expressions which is where the logical
  34. operators are found in the grammar.  So you must, in any mixed logical 
  35. expression, explisitly use parens to specifiy evaulation order and the VAX
  36. compler is correct.
  37.  
  38. --
  39. Mark Biggar
  40. mab@wdl1.wdl.loral.com
  41.