Method starting itself over and over again. A no-no?
Hello! I am somewhat confused now. And I don't even know if I should be confused.
I have this word (excuse my FORTH roots) named PUB MEASURE. At the end I have a "getkeys" and a case to select further actions like PRINT, STORE etc. A few days ago, I was not watching myself and today I noticed that I had added "NEW MEASUREMENT" to the case, and actually was starting MEASURE again. It seems to have worked for quite a while before I found out what bad I had done.
My questions:
1 Is this a working but no-no thing to do?
2 Why does it work (I think it is an effect of the no-stack mechanism, there is no return stack to overflow)
3 Or - is it a perfectly legal way to mess up a program structure?
4 Or - am I completely mistaken - it doesn't work at all. (But it behaves like it works)
5 If it works. Is it part of the Prop thinking - or did it just happen?· :-)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have this word (excuse my FORTH roots) named PUB MEASURE. At the end I have a "getkeys" and a case to select further actions like PRINT, STORE etc. A few days ago, I was not watching myself and today I noticed that I had added "NEW MEASUREMENT" to the case, and actually was starting MEASURE again. It seems to have worked for quite a while before I found out what bad I had done.
My questions:
1 Is this a working but no-no thing to do?
2 Why does it work (I think it is an effect of the no-stack mechanism, there is no return stack to overflow)
3 Or - is it a perfectly legal way to mess up a program structure?
4 Or - am I completely mistaken - it doesn't work at all. (But it behaves like it works)
5 If it works. Is it part of the Prop thinking - or did it just happen?· :-)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
When you start more (SPIN-) COGs you have to provide an extra stack for each of them; those stacks are genaral small. If they overflow disaster is imminent!
There are no good rules for these stack sizes; I generally recommend "20", and when somthing funny happens, enlarge it to 100, and use a "used stack check routine" (I have forgotten where it is, doing mostly machine code
Good to know that it isn't completely illegal.
But the fact that every instantiation eats memory is discomforting. Would that mean that I can do it only so many times - and then bombs?
I have already changed that code. But still interested to hear what would happen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I think you mean "method call" when you say "instantiation" ??
It would be helpful, when you give same code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Yes deSilva. I probably meant "method call", but I didn't want to use that expression since I didn't see it as a call - more as "a use of", which may be the same thing.
Are there any rules as to what to call things in this non-object, but nonetheless somewhat, object oriented language?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
In SPIN "objects" are in fact "static objects", but it would be more appropriate to call them "module templates". They are more than traditional "modules"as they can have a multiplicity, similar to the instantiation of objects in OOP.
This is important to know, as this instantiation can happen accidentially (with most irritating effects) when using a module name in different objects of the program tree.
Post Edited (deSilva) : 9/3/2007 8:39:43 PM GMT