A forum for Spin users
You are not logged in.
Pages: 1
Hi All! First post on spinroot.com!
Any tips on what to do about using GOTO statements in inlines? I see that the spin parser has the concept of a Unique Inline ID (uiid) that it applies to labels, so that I can use the label "FOO" in inline "myFunction1" and also in "myFunction2" and those are two separate labels. But, if I want to call "myFunction1" twice in a proctype, then FOO becomes a duplicated label.
I've written a Perl script that preprocesses my model to deal with this by duplicating my inlines for each time they're called; but is there a better way? Should I be focusing instead on removing the use of GOTO in my inline by using state variables or something like that? (Specifically I want to simulate a "return" statement.)
Thanks
Offline
I can see this was addressed in http://spinroot.com/fluxbb/viewtopic.php?id=159. I was using Spin 6.1.0. Now that I've upgraded to 6.2, this works perfectly! Thanks so much!!!
Offline
Interesting point -- yes this is unintended, but since it is a textual inline it is likely unavoidable.
(It was worse before we added the scope rules to inlines though -- not that this is much of a help here.)
Gotos are of course evil in some way, so the best way would be to avoid using gotos and labels at all.
I don't remember if this is already in version 6.2.2, but there is in fact support for a return statement in inlines....
Just try if it works:
x = myFunction1()
and inside myFunction1() you'll use the standard "return y;"
it's rather limited - because it will not allow you to use an inline in a conditional expression etc, but it's something at least
Offline
Pages: 1