[Info-vax] decrementing & for loops in C
Richard B. Gilbert
rgilbert88 at comcast.net
Fri Jan 9 12:49:01 EST 2009
Bill Gunshannon wrote:
> In article <RBJ9l.9487$cu.6865 at news-server.bigpond.net.au>,
> "Tim E. Sneddon" <tesneddon at bigpond.com> writes:
>> Bill Gunshannon wrote:
>>> In article <49667A6E.3050507 at nowhere.com>,
>>> nobody <nobody at nowhere.com> writes:
>>>> Turning off optimization should normally cause the program to execute
>>>> your program exactly as written.
>>> A program should always execute exactly as written. No machine is smart
>>> enough to second guess the intent of a human.
>>>
>> That is arguable. After your code has been optimised
>> it doesn't quite execute 'exactly as written'. The
>> end result might be 'exactly as written'. However, the
>> path to get there has been completely shuffled around
>> by the compiler.
>
> Well, let's be clear on this. By "exactly as written" I mean just what it
> says. Not "as the writer intended", but "exactly as written". That allows
> for optimizing out code that would never be executed because I wrote the
> code wrong, like the original example. It may not be what I wanted, but
> it is what I wrote. But, the system should not be changing the order of
> operations for any code I wrote because it has absolutely no way of
> determining that there was not a particular reason for doing it in that
> order. No machine (or compiler) is that smart. Someone mentioned Ada
> doing this in an earlier post. Knowing what the primary purposes of Ada
> are, that would really scare me.
> "Let's see. The programmer wants me to check for weight on the wheel
> struts before raising the landing gear. but I think it would be much
> more efficient to raise the gear first." :-)
>
> What, you say that's just silly. How about this?
>
> {
> int thrust_reversers, power_level;
>
> { thrust_reversers = 10; power_level = 20; }
> }
>
> Does the order of these two (apparently) equal operations make a difference?
Possibly. If you accept the implied context of an aircraft about to
land it could make a major difference. Since the largest thing I ever
flew was a de Haviland Beaver (L-20) which wasn't so equipped, I can't
offer more than a SWAG!
> Can a machine determine that?
No! But I wouldn't ask one to do so! If you WOULD, please stay well
clear of me, my family, and my property! And keep your machine and
anything it controls well clear too!!!
More information about the Info-vax
mailing list