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