Re: on goto

Discussion in 'C Programming' started by g3rc4n@gmail.com, Jun 1, 2010.

  1. Guest

    On Apr 24, 11:13 am, "io_x" <> 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
     
    , Jun 1, 2010
    #1
    1. Advertising

  2. On Jun 1, 1:31 pm, "" <> 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
     
    James Dow Allen, Jun 1, 2010
    #2
    1. Advertising

  3. "" <> writes:

    > On Apr 24, 11:13 am, "io_x" <> 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/
     
    Pascal J. Bourguignon, Jun 1, 2010
    #3
  4. Tim Streater Guest

    In article <>,
    Richard Heathfield <> 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
     
    Tim Streater, Jun 1, 2010
    #4
  5. In comp.lang.c++ <> 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.)
     
    Juha Nieminen, Jun 1, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. youngsun park
    Replies:
    2
    Views:
    648
    David Pursley
    Nov 18, 2003
  2. Skybuck Flying

    VHDL Goto statement ?

    Skybuck Flying, Aug 8, 2005, in forum: VHDL
    Replies:
    9
    Views:
    6,400
    ajahn
    Aug 26, 2005
  3. Skybuck Flying

    Re: VHDL Goto statement ?

    Skybuck Flying, Aug 8, 2005, in forum: VHDL
    Replies:
    0
    Views:
    779
    Skybuck Flying
    Aug 8, 2005
  4. Flip
    Replies:
    6
    Views:
    6,783
    Jeff Dillon
    Nov 18, 2004
  5. Flip
    Replies:
    1
    Views:
    676
    Brock Allen
    Apr 14, 2005
Loading...

Share This Page