[Info-vax] decrementing & for loops in C
Bill Gunshannon
billg999 at cs.uofs.edu
Fri Jan 9 13:34:40 EST 2009
In article <wOqdnW_z16MLEPrUnZ2dnUVZ_qLinZ2d at giganews.com>,
"Richard B. Gilbert" <rgilbert88 at comcast.net> writes:
> 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!
There are people here saying they do. They specifically pointed out
Ada as a language where this is common in compilers. And, as I stated,
knowing the primary uses for Ada, I would be very afraid.
> 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!!!
I think you missed something along the way. I'm the one who doesn't
want any machines making any changes to my programs. Compile what I
wrote, mistakes and all. I'll fix them. But no machine should ever
assume it knows more about my job than I do. :-)
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