Open Dunbaratu opened 3 years ago
Many environments provide the exact same environment for interactive use as for script consumption not because it is a richer feature but because it is simpler and easier to code and maintain than not. Interactive use becomes the exact same thing as providing the lines of a 'script' one line at at time. Some command to "clear the decks" is typically provided to clean out anything declared, or short of that you just quit the cli and come back in. I could definitely see how kOS with its requisite trigger levels and asynchronous relationship to KSP/Unity could end up with wrinkles that make this model harder though
In defense of the way kOS is functioning right now is that by not letting LOCALs persist makes it harder to accidentally mask something important with a local and not realize you did that leading to issues when trying to use kOS in CLI mode
That makes a sort of sense. But it is fairly standard when dealing with a 'stale' CLI that its state will be unknown unless you clear it out. On the other hand, if the CLI that remains after a script crashes still has a lot of the declarations in memory it can be a godsend for debugging. A mixed-bag, but there is that silver lining
That can still be done if stuff is global other wise the collapse of the script closes it's local scope which would remove any local vars as the terminal and a script are different scopes. And with kOS we get a lot of people new to programing so what is "standard" is completely unknown to them and so there are concessions to that in the language.
Well, yes and no. If a crash happens in the middle of a deep nested call in many environments a lot of useful info can be found in the autopsy because the scopes that were open at the time of crash are still there. In fact, a lot of interpreted languages CLIs have a lot of capabilities that are the interpreter version of a debugger for compiled languages
Declaring a LOCAL variable at the interpreter makes a variable that is local to the line of text, not to the interpeter context itself. This means that this happens:
Which makes no sense because a line of text shouldn't be getting treated like it was a local scope context (but it is being treated that way, apparently.)