Re: GOTO's

From: Ken Smith (kensmith_at_green.rahul.net)
Date: 01/19/05


Date: Wed, 19 Jan 2005 15:16:44 +0000 (UTC)

In article <pan.2005.01.19.06.23.14.112876@example.net>,
Rich Grise <richgrise@example.net> wrote:
[...]
>And a "GOTO" at the end of it destroys your continuity. A Wend closes the
>loop.

"WEND" is short for "What the hell did that END" You have to put a comment
on it to say what it ended.

> A GOTO can go anywhere, and is more likely to leave crap on the
>stack from the call it's pooping out of.

Someone more expert in C will have to comment on this for C but in Pascal,
no you can't. Jumps out of context are not allowed. Algol had the
"thunk" method to handle the jump out of context. It is quite a good
idea.

> It's a serious bug hole, and
>hellishly difficult to debug.

Given any program that uses GOTOs, you can recode it as one using a loop
enclosing a "switch" statement with the index of the switch being
reasigned within the cases. Thus it is proven that the ability to assign
to a variable is as bad as the ability to assign to the program counter.
  

-- 
--
kensmith@rahul.net   forging knowledge


Relevant Pages

  • Re: [Cbe-oss-dev] [PATCH] Cell OProfile: SPU mutex lock fix
    ... could access the lock outside of the SPU switch notification context. ... data collection in a work queue, because under high load (which is what ...
    (Linux-Kernel)
  • Re: BSD VM architecture...
    ... "discovery" is that this programmatic VM space switch would need to be ... context has a fixed 4Gb address space. ... what you have is effectively the process model ... synchronising processes. ...
    (comp.unix.programmer)
  • [patch] sched: unlocked context-switches
    ... now first switch the stack and registers, ... * finish_task_switch must be called after the context switch, ... * schedule() ...
    (Linux-Kernel)
  • Re: Digital signal controllers
    ... normal stack organization. ... I still don't know of whether it is possible to switch a context for 21xx. ... you return from interrupt they get popped. ...
    (comp.dsp)
  • Re: [PATCH 10/17] 2.6.17.1 perfmon2 patch for review: PMU context switch
    ... Here is a first cut at the patch to simplify the context ... switch for the common case and also touch 2 cachelines. ... There are 2 new TIF flags. ... About the context switch code, what about I do the following ...
    (Linux-Kernel)