[Info-vax] decrementing & for loops in C
Bill Gunshannon
billg999 at cs.uofs.edu
Fri Jan 9 12:35:56 EST 2009
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?
Can a machine determine that?
bill
--
Bill Gunshannon | de-moc-ra-cy (di mok' ra see) n. Three wolves
billg999 at cs.scranton.edu | and a sheep voting on what's for dinner.
University of Scranton |
Scranton, Pennsylvania | #include <std.disclaimer.h>
More information about the Info-vax
mailing list