Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.
Basically a way to force you to have to declare all variables, keeps you from making dumb errors on especially large projects. Yes, you should be doing this in practice anyways, but most people do not.
I would like that. Variable declaration by assignment is prone to errors due to typos when updating the variable's value later, and declaring a new variable with the misspelled name instead.
Unfortunately this is a runtime thing. There is no way to know a variable is declared or not in a script because it has no idea where its being called from, or what instances are being used inside it. This is only known at runtime, hence a runtime crash if you try to read from undefined variables.
Unfortunately this is a runtime thing. There is no way to know a variable is declared or not in a script because it has no idea where its being called from, or what instances are being used inside it. This is only known at runtime, hence a runtime crash if you try to read from undefined variables.
I guess this is why other languages do variable scoping, because then it is knowable at compile time whether the variable has been declared or not in the current scope, so then variables can be explicitly declared.
(I actually look at shortcomings in GML like this as instructive. It has helped me to appreciate why other languages have the features that they do, like private variables, etc. If you never encounter a problem that is prevented entirely by another language's features, then you may not quite appreciate the feature that prevents that problem.)