Forbidden but allowed variable names in codebox
Say I make an codebox object and put in it "accum = 5;"
I will get an error that "accum" is a reserved word and the gen patch will not compile. That seems reasonable.
However, say I didn’t know that "accum" was a reserved word and made a codebox object containing "History accum(5);"
That will destroy the behavior of the gen patch, but there are no warnings that anything is incorrect. I spent an hour troubleshooting a patch with bizarre behavior but no compile errors, only to find that changing "accum" to "accumulator" fixed the behavior issues.
I had the same thing happen in a patch where I was using alphabet letters for a sequence of variable names (A, B, C…). "E" was breaking the patch due to the constant e, but I didn’t get any errors or warnings.
Can someone add warnings or errors to the gen patcher compiler for reserved keywords accidentally used as History variables? Also, is there a list of all the reserved keywords in one place, or should I make my own based on the different sections of the gen~ help file?
They way to think about this is that every constant or operator is already using that name, so pi, e, accum, gate, etc. already exist before your code is added to the mix. There is no definitive list of that has all of these names in a single place right now. If you look at the list of operators in the common gen ops and gen~ ops pages in the Max documentation, that will tell you all of the reserved words.
Your point about the error is noted. What you describe is definitely frustrating. We are working on making things more consistent in terms of error reporting and are aware of this particular issue. Definitely keep sending feedback about this stuff.
Thank you for responding. I understand the nature of reserved keywords, but just wanted to show a perspective from someone starting with gen~. I am used to reserved keywords from other languages, but "accum" and "E" have not been an issue before. I happened to be converting some mxj~ code into gen~ and was copying the variable names. There were no gen compile errors, so I assumed the output was not working because I had a math error somewhere.
I should also clarify what I meant by "destroy the behavior."
If I start with this codebox code…
out1 = in2;
out2 = in1;
…then add a single new line to the top like this…
out1 = in2;
out2 = in1;
…the outputs swap!
Even knowing that accum is a keyword, I would not expect that change in behavior since accum is not actually used anywhere in the code. Here is an example patch for reference:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1171.3oc4YlziaaCEG+rBP9NHvSs.tSDor7RGzC8RaOzuASJFPKwwlIRjBRz yRBZ9rWtnERYIYEGamkdXrF+31e9683ijxe70uxCrg+LoD3+q924648QoEOs MkEuZCdfL7ywo3RcEAw7rLBS.lUUnf7rPWveRXexeCYG9Q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