![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 | |
|
Expert Programmer
|
Quote:
[PHP] for(int index; i < 10; i++) { example code; } [/PHP] the middle part is saying that it will perform the loop while something is true after it is not true it ends the loop. simple concept and a lot easier to understand then "Goto's"
__________________
|
|
|
|
|
|
|
#22 |
|
Newbie
|
You Have A Good Point There. : )
-Still Pouting About How The Sake Affected Him-..... Bad Sake..... (Sake = Japanese Rice Wine , btw.) |
|
|
|
|
|
#23 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4
![]() |
The best argument against goto's that I have ever seen was a memory-game (like making matches of cards and then trying to remember where they were located) I made in TI-Basic on my graphing calculator.
:eek:
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#24 |
|
Newbie
|
Lol!
Honestly, I Cannot Stand The Gotosite Command. I Used it three times, maybe throughout the entire length I have been learning.. (Prolly about 3 months ... LMFAO ) |
|
|
|
|
|
#25 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I think Aethereal STILL doesn't know what's being discussed here. Trade that sake in on a book, and yeah, I know what sake is.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#26 |
|
Newbie
|
Guess I don't.. :-?
.............................. ..................... ............................. Oh well, Maybe I Will Figure It Out Sooner Or Later.... <-- Vb.. Mayhaps it was another language they were mentioning? |
|
|
|
|
|
#27 |
|
Hobbyist Programmer
|
Don't worry about it. Quite honestly, I find it better that beginners never hear the words "goto" in their entire programming life. Unless your name is Linus Torvalds, Richard Stallman, Dennis Richie, or Bjarne Stroustrup, you have no use messing with goto statements. Some people say you should NEVER use them, but their are times when it is acceptable to use them for the sake of performance. Unless you are developing an operating system kernel, a compiler, or advanced robotics/AI software, then I would recommend you pretend as if they never existed. And when I say "for the sake of performance" I don't mean using them instead of loops; I mean using them along side in a very, very scarce manner. There are probebly less than 100 programmers on the face of the planet whom I would trust with using goto statements. Also, while on the topic, for the sake of arguement, you could, in theory, use goto statements in such a way that they would mimic regular loops. Although that would be about as pointless as running a lawn mower through a parking lot.
|
|
|
|
|
|
#28 | |
|
Newbie
|
Quote:
|
|
|
|
|
|
|
#29 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
A goto is no more efficient that a brace, say, in C/C++. Typically, in a high level language, 'goto' is a statement that causes the path of execution to transfer to a point other than the instruction following in normal sequence. This is a common thing and one of the basic reasons our computers work. The destination of the goto is indicated by a label representing an instruction located somewhere else. The scope or range of this "jump" may be restricted, or it may not be. Because it is a unilateral movement, there's nothing that supports any kind of inference as to whether or not the movement is logical or rational, in terms of program flow. If you dissect a "while" loop, you get something like this: TOP: Evaluate expression. If expression is false goto END Do some work here conditioned on the expression being true. Evaluate some expression, if true goto TOP Do some more work here Evaluate some expression, if true goto END Do some more work here END In C, that would look like: while (expr) { Do some work If some expr2 continue More work If some expr3 break Even more work } Note that the 'while' (TOP) is a label who's location is represented by the opening brace. END is a label representing the, well, end Continue is a goto to TOP. Break is a goto to END. Note that VB would use a WHILE....WEND construct. Languages have various syntactical requirements of their own. PL/Z would use DO....OD. Note also that the use of euphemistic things like braces, continue, and break, have a salubrious effect. They localize the operation. They are "in view", so to speak. One can see all the possible paths of instruction flow and the logical orderliness thereof. If the goto shoots off thousands of instructions one has no inkling of the rationale behind the construction of the program. Sometimes it goes off, comes back near, shoots off again, ad nauseum. This is referred to as 'spaghetti code.' One might be tempted (and it might be defensible) to use a goto to exit a deep nest under fatal or near fatal error conditions. It's possible to exit otherwise, but can be a real pain in the rear. Thus the devil tempts us. Linus Torvald and his flunkys overused goto in the kernel. There is some defense, as it is a practical way to deal with exceptional failures, provided you know what you're doing and what needs to be unwound. The BSD kernel, compared to the Linux kernel, is a fine expression of how to do it better.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#30 |
|
Newbie
Join Date: Feb 2006
Posts: 8
Rep Power: 0
![]() |
The GOTO statement (*hints while pointing to aethereal*) should only be used, as someone said earlier for breaking out of loops in the case of error catching. This is its best application.
It can also be used while testing your code. p.s. I could drink a few jugs of warm sake right now, please stop mentioning its yummy/honourable name. . |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|