Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: on goto

Reply
Thread Tools

Re: on goto

 
 
g3rc4n@gmail.com
Guest
Posts: n/a
 
      06-01-2010
On Apr 24, 11:13*am, "io_x" <(E-Mail Removed)> wrote:
> [Xpost to: alt.comp.programming, alt.lang.asm,
> comp.lang.c, comp.lang.c++, comp.programming]
>
> the people that speak not good about "goto"
> are uttled wrong; their code bug full etc
>
> more distant is your code from goto
> more your code is bug full and incompresible
>
> the "goto" is the key word for programming;
> all the remain, other than goto or jmp or jc or jz,
> and the easy cpu layout
> is the wrong way for programming
>
> i advise all you
> Good Morning


it's the least confusing and quickest way to run exit code from a
function

void f(bool param)
{
if(param)
{
// do something
goto on_exit;
}
// something else
on_exit:
// some code that was added a month later
// some code that was added 2 months later
}

opposed to

void f(bool param)
{
struct on_exit_struct
{
~on_exit_struct()
{
// some code that was added a month later
// some code that was added a month later
}
}
on_exit_struct on_exit_;

// code as always
}

which just looks silly and gay

and the sort of people who hate goto probably design there code before
they write it
 
Reply With Quote
 
 
 
 
James Dow Allen
Guest
Posts: n/a
 
      06-01-2010
On Jun 1, 1:31*pm, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
>
> [goto is] the least confusing and quickest way to run
> exit code from a function


Yes. In the subthread about multiple return,
I almost mentioned I used 'goto' to avoid them.

> opposed to [a version] which just looks silly and gay


"Gay"? In which English-speaking country is this
still used to mean "gay: joyous and lively; merry;
happy; lighthearted" ?

> and the sort of people who hate goto probably design
> their code before they write it


Count me among the dinosaurs who start writing functions,
linearly, immediately after deciding to. I sometimes
even add "goto"'s that I know probably should be
"while ... continue".
A minute later, I invest 5 seconds changing the goto's to
continue's, and adding tabs. I'm typing at good speed
and *while typing* it will become clearer whether I need
a "while ... continue" or something slightly more
complicated.
(Now watch the pedants try to beat me to a pulp for
wasting those 5 seconds.)

James
 
Reply With Quote
 
 
 
 
Pascal J. Bourguignon
Guest
Posts: n/a
 
      06-01-2010
"(E-Mail Removed)" <(E-Mail Removed)> writes:

> On Apr 24, 11:13*am, "io_x" <(E-Mail Removed)> wrote:
>> [Xpost to: alt.comp.programming, alt.lang.asm,
>> comp.lang.c, comp.lang.c++, comp.programming]
>>
>> the people that speak not good about "goto"
>> are uttled wrong; their code bug full etc
>>
>> more distant is your code from goto
>> more your code is bug full and incompresible
>>
>> the "goto" is the key word for programming;
>> all the remain, other than goto or jmp or jc or jz,
>> and the easy cpu layout
>> is the wrong way for programming
>>
>> i advise all you
>> Good Morning

>
> it's the least confusing and quickest way to run exit code from a
> function
>
> void f(bool param)
> {
> if(param)
> {
> // do something
> goto on_exit;
> }
> // something else
> on_exit:
> // some code that was added a month later
> // some code that was added 2 months later
> }
>
> opposed to
>
> void f(bool param)
> {
> struct on_exit_struct
> {
> ~on_exit_struct()
> {
> // some code that was added a month later
> // some code that was added a month later
> }
> }
> on_exit_struct on_exit_;
>
> // code as always
> }
>
> which just looks silly and gay
>
> and the sort of people who hate goto probably design there code before
> they write it


void something(){
if(error){
throw Exception("I got you!");
}
}

--
__Pascal Bourguignon__ http://www.informatimago.com/
 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      06-01-2010
In article <(E-Mail Removed)>,
Richard Heathfield <(E-Mail Removed)> wrote:

> Daniel T. wrote:
> > Now watch the pendents on the other side beat me to a pulp for
> > "being so dogmatic."

>
> It's *pedants*, darn you!
>
> But if anyone beats you to a pulp for being so "dogmatic" as to favour
> SESE, that's their problem, not yours. But you needn't worry - they're
> all too busy trying to disentangle their latest masterpiece's control flow.


Well I would be if I were using SESE, that's for sure. I'd follow the
code down to the 20th level of if statement nesting, and then the
comment might say "That's it, all done in this function", and I'd be
wondering "Errrm, how can I confirm that?"

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-01-2010
In comp.lang.c++ http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> it's the least confusing and quickest way to run exit code from a
> function
>
> void f(bool param)
> {
> if(param)
> {
> // do something
> goto on_exit;
> }
> // something else
> on_exit:
> // some code that was added a month later
> // some code that was added 2 months later
> }


Could you please give some *actual* *concrete* well-designed piece of
C++ code where the solution you present above is the easiest, cleanest and
safest way? (Note that C++ code may exit from functions unexpectedly due
to thrown exceptions. Hence your solution must not leak anything even if
an unexpected exception happens in the middle.)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Goto statement ? Skybuck Flying VHDL 9 08-26-2005 01:46 PM
Re: VHDL Goto statement ? Skybuck Flying VHDL 0 08-08-2005 03:21 AM
where does Console.WriteLine() goto in a web app? Flip ASP .Net 1 04-14-2005 08:01 PM
where does Console.WriteLine() goto? Flip ASP .Net 6 11-18-2004 06:05 PM
goto statement is recommened in systemc? youngsun park VHDL 2 11-18-2003 03:47 PM



Advertisments