restart when stuck in a loop
Author |
Message |
Yeti_19
|
Posted: Sat Jul 15, 2006 7:16 pm Post subject: restart when stuck in a loop |
|
|
Hi,
I was wondering if there was a way of restaring my program when it gets stuck in a loop.
Any help would be apreciated.
Thanks,
Yeti |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Clayton

|
Posted: Sat Jul 15, 2006 7:18 pm Post subject: (No subject) |
|
|
not that i know of, the best thing to do would be to make sure that you cant get stuck in a loop  |
|
|
|
|
 |
Delos

|
Posted: Sat Jul 15, 2006 7:55 pm Post subject: (No subject) |
|
|
Indeed. This sort of thing would be known as an infinite loop - methinks that other languages may be able to catch this sort of error and produce an error message.
However, this brings up an interesting thought line, that which is exemplified in the Halting Problem. This particular problem has special importance to us who programme in Turing, as it was proven by our namesake.
Essentially, it asks whether a programme could be made that would be able to analyse other code and determine whether the code would ever terminate (halt). A full review is available at Wikipedia. |
|
|
|
|
 |
Cervantes

|
Posted: Sat Jul 15, 2006 9:07 pm Post subject: Re: restart when stuck in a loop |
|
|
Yeti_19 wrote: Hi,
I was wondering if there was a way of restaring my program when it gets stuck in a loop.
I could interpret this a little differently than you guys seem to have done and say, "Force restart of your program by clicking the 'X' in the window pane, or by clicking 'Stop' in the Turing editor window." |
|
|
|
|
 |
MysticVegeta

|
Posted: Sun Jul 16, 2006 9:56 am Post subject: (No subject) |
|
|
Delos wrote: Indeed. This sort of thing would be known as an infinite loop - methinks that other languages may be able to catch this sort of error and produce an error message.
That seems interesting, perhaps having something like, checking if the values of all the variables are same in the next iteration, and there are NO GUI.Quit buttons working inside the loop, then display the error message? But that seems to have some problems too, what if the person purposely wants it to go to infinite loop because he is testing some sort of an effect he created of drawing something on the screen? by having a "for" loop inside the "loop", for eg:
This will NOT exit the loop:
code: | loop
x += 1
.....
end loop |
This will:
code: | loop
drawoval (x, y, p, q, c) %all vars are constants
end loop |
What about this?
code: | loop
for x : 1..n
drawSomething (blah, blah...)
end for
end loop |
What if in the last example the person is testing some of his graphics? It would exit it just after the 1st iteration?
Perhaps, for those problems, they could make another command like "noexit" if the user does not want it to exit..
code: | loop
for x : 1..n
drawSomething (asdf);
end for
[b]noexit[/b]
end loop |
What do you guys think about this? |
|
|
|
|
 |
Cervantes

|
Posted: Sun Jul 16, 2006 10:50 am Post subject: (No subject) |
|
|
"noexit"? Oh dear...
It's good the way it is, and it's been good like that for years upon years. If the programmer wants an infinite loop, he'll make one.
Making your language exit from a loop that never changes state, a loop that should be infinite, a loop like this
code: |
loop
drawoval (x, y, p, q, c) %all vars are constants
end loop
|
Making your language exit from a loop like that breaks the principle of least surprise. That should clearly loop forever. If the programmer didn't want that to loop for ever, he wouldn't have put the loop .. end loop in.
Also, what if this code were within its own separate thread? Your loop would exit unexpectedly and you wouldn't get the desired results. |
|
|
|
|
 |
MysticVegeta

|
Posted: Sun Jul 16, 2006 6:02 pm Post subject: (No subject) |
|
|
yes but then he could put "noexit" after. eh?
Since Turing is a lang designed for programming beginners like myself, I would prefer it to output some sort of message when stuck in an infinite loop, would really help when coding some problems for contests/games even. But thats just me speaking lol, they are not gonna do it for 1 person who uses turing 1nce a month. lol |
|
|
|
|
 |
Cervantes

|
Posted: Sun Jul 16, 2006 7:31 pm Post subject: (No subject) |
|
|
As a learning language, it should be simplistic. Adding some aspect to the language that gives you an error when you're in an infinite loop is not a good idea because it (A) breaks the principle of least surprise and (B) forces the student to learn more concepts such as "noexit", concepts that don't exist anywhere else.
But I have no qualms with the IDE having an infinite-loop-detecter. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
MysticVegeta

|
Posted: Sun Jul 16, 2006 9:08 pm Post subject: (No subject) |
|
|
Yes I completely understand that. But look at the following:
code: | put "Hello", skip, "World"
put ""
put "Hello\nWorld"
|
Why would they use the skip to accomplish something.
Quote: concepts that don't exist anywhere else. skip is one of them
What about and
Heck, they arent even different in anyway. They just made it to do what? "Help English and American students learn the language in the way they prefer?"
I mean so many other useless functions exist... that do not exist in other languages... I think they should set it up, it would be good for beginners, and maybe create an option...?
-> Beginner mode
-> Advanced mode
Not only this thing, but many others differentiating each category. I dont know what the hell I am saying anymore  |
|
|
|
|
 |
Cervantes

|
Posted: Sun Jul 16, 2006 10:13 pm Post subject: (No subject) |
|
|
MysticVegeta wrote:
Quote: concepts that don't exist anywhere else.
skip is one of them
'skip' isn't much of a concept. It's a minor, insignificant thing. Modifying the behaviour of loops, on the other hand, is major.
'colour' vs. 'color' is just so that you can use whichever you prefer. I don't see the problem. Additionally, 'colour' and 'color' are just procedures, not vast concepts.
Are we through now? |
|
|
|
|
 |
MysticVegeta

|
Posted: Sun Jul 16, 2006 11:52 pm Post subject: (No subject) |
|
|
lol yeah I guess... I could go on but that would just make me look like a fool lol so yeah... but neways, I did say from just my point of view... meh, it was just an idea.  |
|
|
|
|
 |
|
|