home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / scheme / 2849 < prev    next >
Encoding:
Internet Message Format  |  1993-01-01  |  1.9 KB

  1. Xref: sparky comp.lang.scheme:2849 comp.lang.c:19120
  2. Newsgroups: comp.lang.scheme,comp.lang.c
  3. Path: sparky!uunet!noc.near.net!viewlog.viewlogic.com!josh
  4. From: josh@viewlogic.com (Josh Marantz)
  5. Subject: Re: applying or
  6. Message-ID: <1993Jan1.184655.7023@viewlogic.com>
  7. Sender: news@viewlogic.com
  8. Nntp-Posting-Host: concept
  9. Organization: Viewlogic Systems, Inc.
  10. Date: Fri, 1 Jan 1993 18:46:55 GMT
  11. Lines: 27
  12.  
  13.  
  14. >A large number of _later_ Algol derivates contain the 'and then' and 'or then'
  15. >control constructs.  The reasoning in seperating them was that in many cases
  16. >the conditional evaluation was required for correct code (as in a check for
  17. >divide-by-zero or null-pointer-dereference), but that WHERE IT WASN'T
  18. >(required) the compiler could generate more efficient code for 'and' and 'or'
  19. >by having the choice of which to evaluate "first."  (What's currently in the
  20. >machine registers?  Hmmm....)  So take your pick of Algol, Simula, SAIL, etc.
  21.  
  22. At DEC, using Vax PL/I, there were many cases where code checked for
  23. NULL pointers and then dereferenced them after an AND.  The code would
  24. work perfectly when the optimizer was on, but if you turned it off,
  25. say to debug, the code would break.  Before there was a decent Vax
  26. Debugger, many people developed large applications with this style,
  27. never compiling without the optimizer.  With the advent of the
  28. debugger, the code stopped working!
  29.  
  30. I was sort of glad to move to C/Scheme, where this short-circuiting
  31. was guaranteed, although I never thought about the compiler
  32. optimizations that the short-circuit guarantee prevents!  Would it be
  33. legal for a C or Scheme compiler to avoid the short-circuiting if it
  34. could prove there were no side effects involved, and if it looked like
  35. a fruitful optimization?
  36. -- 
  37. Joshua Marantz                          You make my life and times
  38. Viewlogic Systems,                        a book of bluesy Saturdays
  39. josh@viewlogic.com                      And I have to choose...
  40.