Forbidden but allowed variable names in codebox

    Mar 03 2012 | 10:46 pm
    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?

    • Mar 03 2012 | 11:10 pm
      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.
    • Mar 03 2012 | 11:51 pm
      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...
      --- History accum(0); 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: