[OT] [sdiy] IN your mind, what is ....
Michael E. Caloroso
analoguediehard at att.net
Wed Feb 4 16:08:57 CET 2004
>>Not a simpler solution, but it keeps the pointer stack clean which is a
>>goto cannot do.
>
Forbes, William - EE - UK/Leamington wrote:
> 'continue' and 'break' (except in a switch statement) are effectively
> goto's!
> The all cause a jump and the effects on maintainability can be just a
> severe as a goto!
> Why work round a 'goto' when a 'goto' is the most sensible thing to
> use?
Don Tillman wrote:
> If the operation you're doing is a naturally GOTO-like operation, what
> is so freaking horrible about implementing it with a GOTO instruction?
Rainer Buchty wrote:
> A goto statement does *not* affect the stackpointer. It's the counterpart
> to JMP/BRA in assembly language. All it does, is setting the program
> counter. The stack pointer is influenced by gosub or, for that matter, any
> function or procedure call.
Therein lies the crucial difference between goto and continue/break.
continue/break keep you *inside* the function. This keeps the stack
clean as you will always encounter each RET call associated with its
GOSUB call.
goto statements can take you *outside* the function. Do this and now
you have pointers in the stack that are invalid. This fragments the
stack, raising the spectre of stack overflow and a system crash.
Framented memory is the bane of code that runs 24/7.
I have done plenty of code optimization of legacy code. Fragmented
memory is one of the worse offenders and is a topic that too few
developers are aware of. Removing fragmented memory can extend code
MTBF from a few hours to weeks.
Yes they may compile as JMP/BRA statements but it is the implementation
that is the difference.
WRT code reliability, that's a clearer way of doing it. The political
correctiveness of eliminating goto's is irrelevant when the target
application is critical like medical monitoring apparatus or aerospace
controls. If I ever set foot on a plane that contains some of my
design, you better believe I went the extra mile to confirm reliability
as the last place to encounter stack overflow/system crash is at
30,000ft above ground. That's what is so freaking horrible about a goto
statement.
MC
More information about the Synth-diy
mailing list