Spinroot

A forum for Spin users

You are not logged in.

#1 2012-10-26 16:00:45

dschumann
Member
Registered: 2012-10-26
Posts: 3

goto's in inlines

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

#2 2012-10-26 19:24:42

dschumann
Member
Registered: 2012-10-26
Posts: 3

Re: goto's in inlines

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

#3 2012-10-26 19:47:51

spinroot
forum
Registered: 2010-11-18
Posts: 694
Website

Re: goto's in inlines

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

#4 2012-10-26 19:48:19

spinroot
forum
Registered: 2010-11-18
Posts: 694
Website

Re: goto's in inlines

should have read your second post before i responded to the first :-)

Offline

Board footer

Powered by FluxBB