Re: help with c++ if test

Huh?  How is the code more searchable for you?  If you want it more
compact, stick your functions in a header file and #include it into
your main source file.  Then, all you have to do to edit your
functions is pull them up in their own small, compact header file and
fix them from there.  This is nice because the rest of the code that
calls them need not be modified.  This is actually still true for
these examples even if you put them in the same .cpp file that called
them but, in longer code, separating your code into different files is
a very good idea.  Either way you go, everything I have read in the
admittedly short time I have known how to write anything in c++ tells
you to avoid it like the plague.  If the people on this list are
telling you to stay away from it, it's a good idea to listen.  Or, if
you still wish to persist, try the c-prog list for c++ programmers
but, be warned, they do not suffer fools gladly and they will consider
your use of goto in this instance foolish and will tell you so in no
uncertain terms.  They will also send you link upon link to reference
materials backing up why they think you shouldn't do this.  When they
are tired of doing that and you still persist, they will ignore you
but not after telling you all about yourself with all the glorious
"tact" hardcore hackers are known for the world over.  Also, be
prepared to show plenty of code on that list.  Try it, you may learn
something.  People on there are fountains of information.  Don't
expect coddling though.

Alex M

On 2/9/11, Kristoffer Gustafsson <kg84@xxxxxxxxxxxx> wrote:
> Hi.
> For me it will be more easy to use goto, because with labels  the code
> becomes more searchable for me.
> If I had known how I should get the code to work I hadn't written to this
> list.
> DO you want to help me with this or not?
> /Kristoffer
>   ----- Original Message -----
>   From: Littlefield, Tyler
>   To: programmingblind@xxxxxxxxxxxxx
>   Sent: Wednesday, February 09, 2011 8:24 PM
>   Subject: Re: help with c++ if test
>
>
>   >If you know how to use it why do you need help?
>   ken++
>   On 2/9/2011 12:20 PM, Ken Perry wrote:
>     If you know how to use it why do you need help?
>
>
>
>     ken
>
>
>
>     From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Kristoffer
> Gustafsson
>     Sent: Wednesday, February 09, 2011 2:17 PM
>     To: programmingblind@xxxxxxxxxxxxx
>     Subject: Re: help with c++ if test
>
>
>
>     Hi.
>
>     Yes, I've heard that goto is bad a lot of times. But it is goto that I
> know how it works, and I'll use goto in my text games.
>
>     So can you please help me to see what is wrong with the code I sent?
>
>     I want to jump between labels with goto.
>
>     /Kristoffer
>
>       ----- Original Message -----
>
>       From: Sina Bahram
>
>       To: programmingblind@xxxxxxxxxxxxx
>
>       Sent: Wednesday, February 09, 2011 8:10 PM
>
>       Subject: RE: help with c++ if test
>
>
>
>       Yes, regardless, goto is bad.
>
>
>
>       But absolutely you can break out of the inner loop, but then you'll be
> in the top level loop, in which you can do a conditional.
>
>
>
>       This is still more efficient, since it is definitionally true that you
> would do a check in the inner loop before your goto, and if you are doing a
> check in the inner loop, then that means you are doing a check M*n times,
> where m and n are the dimensions of the outer and inner loops, respectively.
>
>
>
>       If you remove that, and simply do the check in the outer loop, then
> you are only doing a check m times, which is an entire order of complexity
> better.
>
>
>
>       Goto is bad. This is the one rule where because I say so and other
> inane excuses from teachers is acceptable. Goto is just bad. There is no
> reason, none, what-so-ever, that you need one.
>
>
>
>       Now, if we get into kernel programming where assembler is being linked
> in, etc, etc, then we can talk . but in something as straight forward and
> earth shatteringly simple as the logic for an adventure game? Goto is
> absolutely in no way necessary under any possibly conceivable permutations.
>
>
>
>       Take care,
>
>       Sina
>
>
>
>
>
>
>
>       From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield,
> Tyler
>       Sent: Wednesday, February 09, 2011 2:05 PM
>       To: programmingblind@xxxxxxxxxxxxx
>       Subject: Re: help with c++ if test
>
>
>
>       Sina:
>       Break is awesome when you have one single loop, but you can't break
> out of two loops, can you? It was just the first thing that came to mind
> because I've seen it used (and used it) like that.
>
>       On 2/9/2011 11:50 AM, Sina Bahram wrote:
>
>       tyler, this is a horrible example of goto, my friend.
>
>
>
>       That's what break is for.
>
>
>
>       Take care,
>
>       Sina
>
>
>
>       From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield,
> Tyler
>       Sent: Wednesday, February 09, 2011 1:17 PM
>       To: programmingblind@xxxxxxxxxxxxx
>       Subject: Re: help with c++ if test
>
>
>
>       I really really highly recommend you avoid goto. This isn't basic, and
> they're not very useful except for in some odd cases, far and few between.
> Such as jumping out of two nested loops like so:
>       int i, j;
>       for (i = 0; i < 100; i++)
>       {
>       for (j = 0; j < 100; j++)
>       {
>       if (i+j == 100)
>       goto botttom;
>       }
>       }
>       bottom:
>       //do something here
>       if you want to compare strings, do something like this:
>       if (input == "north")
>       {
>       GoNorth();
>       }
>       else if (input == "south")
>       ...
>       else ...
>
>
>
>       On 2/9/2011 10:52 AM, Kristoffer Gustafsson wrote:
>
>       Hi.
>
>       I'm writing if tests in c++ with the goto command.
>
>       I want to do text games and I'm using these commands for that.
>
>       But it doesn't work, so I must do something wrong.
>
>       Can you give me an example how this is done with a string please?
>
>       /Kristoffer
>
>
>
>
>
> --          Thanks,    Ty
>
>
>
>
> --      Thanks,  Ty
>
>
> --
>
> Thanks,
> Ty
>
__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: