Talk:Petit Computer 3/@comment-15296152-20140705040614/@comment-15296152-20140710182718

Well, checking PTC, while commands are likely tokenized, variable names have to manually be dealt with every time, which means they have to be parsed, then searched in a variable list, then retrieve/write a value from/to it. A variable name "AAA" is slower to execute than "AA", which is slower than "A". If they were tokenized, then the tests I made would have them all complete at the same time. Constant values and strings are simply parsed and converted to the required format. The thing though is that PTC has a limit of the numberof variables that can be stored (which is 2048, which can be any mix of numeric and string. Arrays count as one, based on the name), so technically, they could have tokenized variables if they wanted to, but they didn't. It could be because they limited themselves to 1-byte tokens (up to 256 different tokens). I will assume it is because of the "space" character, which is 1 byte each.

Maybe they developed PTC3 with the idea of tokenizing variables and constant numbers/strings, assuming they still work under a limited number of variable names. If they did, that could explain the boost in processing speed. Dunno about 100x, but it sure would be a lot faster to execute without having to parse and search. I could see it in a global variable environment, but in a local variable environment (like a function), it would be a bit more tricky, but still manageable. I haven't thought it out through, but would likely involve their own variable stack, having them tokenized as if the function expanse was it's own individual program, allocate those variables onto the stack when a function is entered (and mark where the variables begin) and deallocate them when leaving the function (placing the marker where it previously was earlier on in the stack). This would allow recursion (like if a function calls itself), and still maintain the ability to tokenize variables. Slightly slower than global variables (because it has to index in relation to the marker, which at the very least is an extra addition operator internally), but unique in their own little world.