Re: GOTO's

From: Rick Thompson (nospam_at_nospam.com)
Date: 01/19/05


Date: Wed, 19 Jan 2005 15:28:03 +0000

On Wed, 19 Jan 2005 15:16:44 +0000 (UTC), kensmith@green.rahul.net
(Ken Smith) wrote:

>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.

Not possible in C/C++. goto can only branch within a function, and
will clean up any stacks created by blocks that you leave.
setjmp/longjump are also stack-clean, by definition.

Rick



Relevant Pages

  • The stack and longjmp/setjmp
    ... The stack is one of the central structures in C. ... we come to the interactions of longjmp/setjmp (and also ... This is not possible in standard C but there are proposals ... a simple "goto" can make things quite messy: ...
    (comp.lang.c)
  • Re: Effect of goto on local variables
    ... > program logic where I have to retry calling some repeated functions. ... > Can anybody help in the usage of goto and its effect in local ... Local Variables would be stored in the stack. ... it would have stored the current contents of the registers back on ...
    (comp.lang.cpp)
  • Re: Non-recursive in-order binary tree traversal
    ... I knew this solution would involve the use of a stack or some other ... void PrintTree ...     Node* node ... Pretty this up by replacing goto with while: ...
    (comp.programming)
  • [PATCH 1/4] reduce kvm stack usage in kvm_arch_vm_ioctl()
    ... This is mostly because gcc fails to ... stack usage combined. ... unsigned int ioctl, unsigned long arg) ... goto out; ...
    (Linux-Kernel)
  • Re: I take it all back...
    ... >10 Print "WHSmiths is crap" ... >20 Goto 10 ... 20 POKE ... 30 PRINT "COUNTDOWN! ...
    (uk.rec.cars.modifications)

Quantcast