Why we implemented Goto in Script Runner
COSMOS release 6.4.0 added the keyword 'goto' and associated GUI option to Script Runner. I almost immediately got an email from an old Ball Aerospace colleague asking if we had "sold out"! This is a humorous reference to many conversations we had over the years at Ball Aerospace resisting the implementation of 'goto' in COSMOS. Why were we so adamant about not implementing goto and why have we now added this feature?
Goto is considered bad programming practice because:
Basically 'goto' makes your code harder to write, harder to read, harder to debug, and it is made obsolete with modern programming languages. This was the argument we always made as well trained Software Engineers: goto == bad.
However, imagine you're a test engineer needed to re-run an entire section because a cable was loose or someone forgot to turn on some hardware. Or maybe you're wringing out a new script and are simply debugging (perhaps even in Disconnect Mode). In this case we're not talking about program structure or long-term maintenance but short term execution. We've supported the ability to "execute while paused" in COSMOS 4 and the more we thought about it, goto is effectively doing the same thing.There are many reasons to want a goto, especially during assembly, integration and test, that we finally added it to our scripting support in both Ruby and Python.
So while you should NOT use goto as a way to structure your scripts, you can now use it to help debug and execute when trouble occurs. Our customers drive the direction of COSMOS and we implemented this to support one program in particular. Now that feature flows to all COSMOS users so enjoy 'goto' in COSMOS 6.4.0! Just don't abuse it! :-)