[Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7
Date | 2025-08-18 14:43 |
From | joachim heintz |
Subject | [Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7 |
it is really big fun to work in CS7 --- great work done by victor and the others!!! i would like to mention here one minor and one major issue for the current rule in CS7 that variable and instrument names are not allowed to use names of opcodes. the minor issue: we have more than 1500 opcodes so it is a pity that many useful names like "start" and "play" are not possible. but the major issue is this: when in future new opcodes are introduced, they will break existing code. (e.g. i used the variable name "max_rec" and an opcode is introduced with this name.) how do others look at this subject? best - joachim |
Date | 2025-08-18 15:33 |
From | Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd-dev] [EXTERNAL] [Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7 |
That's not exactly a rule, but a side effect of having all opcode names as read-only variables. When we introduced the opcode ref type, we thought it was a good idea to make all relevant opcodes variables so they can be used without any extra annotation. The downside is that variables cannot be redefined and so if you try to use them for anything else you will get a syntax error. It may be possible to look at supporting redefinition - not sure how hard that is or if it is possible without breaking stuff. The other alternative is not to have these opcode variables in the system. The result is that to use an opcode ref we would need to declare a variable first. Prof. Victor Lazzarini Maynooth University Ireland > On 18 Aug 2025, at 14:44, joachim heintz |
Date | 2025-08-18 15:57 |
From | Steven Yi |
Subject | Re: [Csnd-dev] [EXTERNAL] [Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7 |
I think redefinition should be allowed, as well as name shadowing between local and global scope, but it'd be tricky. The compiler checks vars in the global table and if it finds it, it uses it. It's hard to come up with a rule that'd permit local scoped var vs. working with the global scope. Could possibly use a keyword like 'local' to explicitly say a new var is being defined locally and to be used for duration of compilation of the instrument, but that doesn't prevent the problem of existing working code becoming invalid if a new opcode is introduced with the same name. Need to think through this a bit more though. On Mon, Aug 18, 2025 at 10:33 AM Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote: That's not exactly a rule, but a side effect of having all opcode names as read-only variables. |
Date | 2025-08-18 23:04 |
From | Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd-dev] [EXTERNAL] [Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7 |
I agree that these are desirable things.
I went ahead and tried an idea to allow for redefinition. It seems to work and it is fairly straightforward code. I'll play with it and make a PR when it's ready. We can then decide to adopt it or not.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 18 Aug 2025, at 15:58, Steven Yi <stevenyi@gmail.com> wrote:
|
Date | 2025-08-19 02:06 |
From | Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd-dev] [EXTERNAL] [Csnd-dev] one issue with variable names not allowed to meet opcode names in CS7 |
PR #2241 implements these ideas.
With this, we can have things like
play:i init 0
redefining the 'play' variable. etc
Prof. Victor Lazzarini
Maynooth University
Ireland
On 18 Aug 2025, at 23:04, Victor Lazzarini <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
|