SMath Studio Forum
»
SMath Studio
»
Bugs & Problems
»
bad recursive function calling causes crash
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello,
Try this one:
f(x)←line(x←x+1,f(x),2,1) f(5)=#
This will cause SMath to crash. Just wondering how to suppress the bad recursive function calls and to avoid crashes.
Regards, Radovan |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 04/07/2010(UTC) Posts: 178 Was thanked: 19 time(s) in 13 post(s)
|
|
Ed |
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello Ed,
I agree that we have to pay attention when writing such functions. In fact, I think we should try to avoid them at all, if possible. Just crossed my mind that if I make a mistake and get into some indefinite loop or the calculation is taking to long, I can interrupt the calculation. On the other hand, I do not feel comfortable when I know that a mistake like unintentional recursive call could crash the SMath. I am not a programmer and I do not know if there is something that could be done in order to avoid such crashes. If not, we just have to accept that and be extra careful.
Regards, radovan
|
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
omorr wrote:Just crossed my mind that if I make a mistake and get into some indefinite loop or the calculation is taking to long, I can interrupt the calculation.
Hello. Your sample doesn't cause crashes in my pc with the prior version of SMath. You can interrupt the current calculation, bordered in green, by pressing the stop icon. It might be useful to have SMath provide some report about the callings involved in an interrupted calculation. Edited by user 05 December 2011 00:08:18(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello, kilele wrote:omorr wrote:Just crossed my mind that if I make a mistake and get into some indefinite loop or the calculation is taking to long, I can interrupt the calculation.
Hello. Your sample doesn't cause crashes in my pc with the prior version of SMath. You can interrupt the current calculation, bordered in green, by pressing the stop icon. It might be useful to have SMath provide some report about the callings involved in an interrupted calculation. Yes, you are right. Version 0.89 stable will not crash and we can interrupt the calculation. It can be considered as expected behavior. Therefore, I think that this might be a bug in 0.89.8 beta version. About reporting the callings, I suppose this might be connected to the debugger . It started by uni more than a year ago. It might be quite helpful in writing functions but I do not know the progress of it. Regards, Radovan Edited by user 05 December 2011 02:57:11(UTC)
| Reason: Not specified |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello, There is some change in v.0.90 about recursive function calls, as Andrey pointed out. Here are some simple testing examples which show some different behavior regarding recursive function calls. The previous trivial example will not cause crash anymore: f(x)←line(x←x+1,f(x),2,1) Although we can have the symbolic answer, the numerical answer will give the error that the function is undefined. f(x)—f(2+x)f(-8)=#@#Here is another one: ff(x)←line(x←x+1,if(x<10,ff(x),y←x),y,3,1)ff(x)—3+xLets try to get some numerical answer ff(8)=#@# ff(12)=13For 8 the result is undefined function but for 12 there is a result Lets make another function by just assigning the previous one, and try the same fff(x)←ff(x) fff(x)—3+xfff(8)=11 fff(12)=15Now we get the result. To be honest, I am a bit puzzled here. Do not get at the moment what happened. Andrey, could you give us the answer what has going on and how to understand this please? Regards, Radovan Edited by user 10 January 2012 04:39:29(UTC)
| Reason: Not specified |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
SMath Studio Forum
»
SMath Studio
»
Bugs & Problems
»
bad recursive function calling causes crash
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.