Talk:Petit Computer 3/@comment-15296152-20140501232225

I noticed in the confirmed features involving functions and local variables with the tag - Apparently, this is exciting. I can tell you right now that it dang well is exciting.

From one point of view of global varaibles, it may seem nice, but the problem with global variables is that you have to start making unique names, which end up having to become longer with the more variables you make. With local variables, you won't have to. Using a simple name like "I" for a FOR/NEXT loop within a function won't interfere with another variables also called "I" in a different function. What's the point? Well, what if one FOR loop using "I" for the incrementor has within it a call to a function that also contains a FOR loop? In PTC (using GOTO/GOSUB for mimicking functions), using the same name like this would cause problems in those loops. In PTC3D with local varaibles, it won't cause a problem. Plus, the added capability of local variables will radically change how long it will take for the interpreter to parse and read variables. Every jump into a function causes the previous varaibles on the stack to "freeze", meaning examination of parsed variables from within this new jump to a function will begin at the end of this "freeze" point. It's scope for those that understand. Rather than having to examine all the variables ever made (which could be in the tens of thousands with PTC3D), it'll only have to check the dozen or so within the functions themselves, plus any that are designated "global". That is a lot of time cut off for reading/writing.

As for functions, they are very important as well. It allows you to make a unique set of calculations that could be a number of lines long, and then allow you to call the function. While you could say the use of GOSUB could do the same trick (and it does with PTC), the true nature of functions allows those local variables rather than having to use global variables to get the job done, which include parameters that get added for functions.

These additions not only make your code more organized, but they'll make your code run faster by comparison.