Gennady Bystritsky
8/15/2006 10:24:00 PM
> -----Original Message-----
> From: Nathan Smith [mailto:nsmith5@umbc.edu]
> Sent: Tuesday, August 15, 2006 3:09 PM
> To: ruby-talk ML
> Subject: Re: goto function?
>
> On Wed, 16 Aug 2006, David Vallner wrote:
>
> > On Tue, 15 Aug 2006 23:05:10 +0200, fabsy
> <fabbyfabs@gmail.com> wrote:
> > > I want the script to start over again.. for example..
> > > When the user made an input and pressed return I want the
> script to
> > > "restart" or jump to the beginning..
> > >
> >
> > Let me introduce you to my good friend: structured
> programming. I'm sure
> > you'll get along marvelous once you get to know each other.
> >
> > The BASIC construct of "goto" is rightfully considered harmful for
> > programs above a certain complexity. It's not present in Ruby in any
> > direct way that would let you jump around a program's structure
> > arbitrarily. (Actually, that's a lie, but I'll hold the
> continuations for
> > the sake of simplicity.)
>
> <snip>
>
> Obligatory response:
>
> In some very rare circumstances, using gotos does in fact
> have a rightful
> place in code. In very long switch/case statements in C code, a _very_
> well structured (and properly named) set of labels/gotos can make code
> much cleaner, and easier to understand, than if they were not
> used. But
> I'll say again, this is very rare.
I have to respectfully disagree. Having actively used C (among many
others) since 1986 up until now for professional development, I NEVER
found a good use for it, even in my early days. Especially in
switch/case statements ;-). It may be _very_ well structured in the
beginning, becoming a total mess with time. Never had very long
switch/case statements even on very big projects either. This is where
lookup tables with function pointers come in handy, for one.
Gennady.
>
> Nate
>
>