Open gesellkammer opened 7 years ago
I agree that something like this would be beneficial, but one issue that may arise — and I may be mistaken about this — is that while names of opcode arguments are documented in the manual, opcode arguments don’t really have names under the hood. Implementing this may entail adding names of arguments to all opcodes so that Csound would know something was amiss with, say
asig = mincer(atime, kamp, table: ktab, pitch: kpitch, BAD_ARGUMENT_NAME: 2048)
Also — and this is a bit of a corner case — there may be some grammar ambiguities here because line breaks are permitted after commas. So, if written this way
asig = mincer(atime, kamp,
table: ktab, pitch: kpitch, fftsize: 2048)
table:
would be treated as a label (for a goto
statement). Now, one could have a rule that you can’t have labels in parentheses like that, but if written this way
asig mincer atime, kamp,
table: ktab, pitch: kpitch, fftsize: 2048
you’d have the same problem. That might still be fixed by paying attention to trailing commas, but the point is that this would have far-reaching effects.
The syntax proposed is just the first thing that came to mind, the request is not bound to the usage of the sign ":" to define argument names. Regarding defining names for all arguments in all opcodes: they are already defined in the manual, so it would be a matter of just copying them, or just leaving these opcodes untouched and only providing names for new(er) ones. Opcodes which (still) don't define names would not accept named arguments.
I do not like this idea; names should not matter
Named arguments (or an equivalent, like passing an object literal to a JavaScript function) appear in many widely-used languages (Objective-C, Python, and Swift come to mind); and class names, function names, argument names, etc. would seem important to the comprehension of a program. I’m of the opinion that named arguments would be a beneficial, but difficult-to-implement, addition to Csound.
I'd emphasize the difficult to implement side. It would need quite a bit of surgery to the parser and compiler code.
I would ather not have tis. Apart from being a pain to implement am not convinced tat it isa good idea
This hasn't been discussed for a while, but I would like to give a +1 for named arguments. It would make code much easier to read imho (especially for new users of Csound) and easier to deal with optional arguments. Since its difficult to implement, its of course still a discussion if that's something the devs should prioritize, but I think it would be a great addition to Csound.
Please no. It is not just the implementation, but also verbosity, naming arguments in a way that is meaningful to users, and encouragement of bad thinking.
Just my view.
Sent from TypeApp
On Sep 28, 2018, 15:02, at 15:02, "Bernt Isak Wærstad" notifications@github.com wrote:
This hasn't been discussed for a while, but I would like to give a +1 for named arguments. It would make code much easier to read imho (especially for new users of Csound) and easier to deal with optional arguments. Since its difficult to implement, its of course still a discussion if that's something the devs should prioritize, but I think it would be a great addition to Csound.
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/csound/csound/issues/745#issuecomment-425445216
What do you mean by "encouragement of bad thinking"? Also arguments already have names that users have to deal with in the manual, so I dont really see the difference in putting them in the code too.
On Fri, 28 Sep 2018 at 17:14, John ffitch notifications@github.com wrote:
Please no. It is not just the implementation, but also verbosity, naming arguments in a way that is meaningful to users, and encouragement of bad thinking.
Just my view.
Sent from TypeApp
On Sep 28, 2018, 15:02, at 15:02, "Bernt Isak Wærstad" < notifications@github.com> wrote:
This hasn't been discussed for a while, but I would like to give a +1 for named arguments. It would make code much easier to read imho (especially for new users of Csound) and easier to deal with optional arguments. Since its difficult to implement, its of course still a discussion if that's something the devs should prioritize, but I think it would be a great addition to Csound.
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/csound/csound/issues/745#issuecomment-425445216
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425449198, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyXr-Ztbyht1y-2FUc456jv2edXFTtSks5ufi7XgaJpZM4LoIZi .
-- Mvh.
Bernt Isak Wærstad
can you give an example? not sure what you exactly mean.
On 28/09/18 16:20, Bernt Isak Wærstad wrote:
What do you mean by "encouragement of bad thinking"? Also arguments already have names that users have to deal with in the manual, so I dont really see the difference in putting them in the code too.
On Fri, 28 Sep 2018 at 17:14, John ffitch notifications@github.com wrote:
Please no. It is not just the implementation, but also verbosity, naming arguments in a way that is meaningful to users, and encouragement of bad thinking.
Just my view.
Sent from TypeApp
On Sep 28, 2018, 15:02, at 15:02, "Bernt Isak Wærstad" < notifications@github.com> wrote:
This hasn't been discussed for a while, but I would like to give a +1 for named arguments. It would make code much easier to read imho (especially for new users of Csound) and easier to deal with optional arguments. Since its difficult to implement, its of course still a discussion if that's something the devs should prioritize, but I think it would be a great addition to Csound.
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/csound/csound/issues/745#issuecomment-425445216
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425449198, or mute the thread
-- Mvh.
Bernt Isak Wærstad
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425450928, or mute the thread https://github.com/notifications/unsubscribe-auth/ACGDqp1TXPSYSpnVbCA0KANCWCpcukptks5ufjAZgaJpZM4LoIZi.
Did you mean me or John, Joachim?
On Fri, 28 Sep 2018 at 17:24, joachimheintz notifications@github.com wrote:
can you give an example? not sure what you exactly mean.
On 28/09/18 16:20, Bernt Isak Wærstad wrote:
What do you mean by "encouragement of bad thinking"? Also arguments already have names that users have to deal with in the manual, so I dont really see the difference in putting them in the code too.
On Fri, 28 Sep 2018 at 17:14, John ffitch notifications@github.com wrote:
Please no. It is not just the implementation, but also verbosity, naming arguments in a way that is meaningful to users, and encouragement of bad thinking.
Just my view.
Sent from TypeApp
On Sep 28, 2018, 15:02, at 15:02, "Bernt Isak Wærstad" < notifications@github.com> wrote:
This hasn't been discussed for a while, but I would like to give a +1 for named arguments. It would make code much easier to read imho (especially for new users of Csound) and easier to deal with optional arguments. Since its difficult to implement, its of course still a discussion if that's something the devs should prioritize, but I think it would be a great addition to Csound.
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/csound/csound/issues/745#issuecomment-425445216
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425449198, or mute the thread
.
-- Mvh.
Bernt Isak Wærstad
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425450928, or mute the thread < https://github.com/notifications/unsubscribe-auth/ACGDqp1TXPSYSpnVbCA0KANCWCpcukptks5ufjAZgaJpZM4LoIZi .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csound/csound/issues/745#issuecomment-425452245, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyXr7jAo8SFR9YKmBf5WPK_IzZQv0dQks5ufjERgaJpZM4LoIZi .
-- Mvh.
Bernt Isak Wærstad
I think something like this is a good idea. I've used this type of feature in other languages and it does help the readability of code. I know I find it difficult to keep track of parameters especially for opcodes like partikkel. I wouldn't say it would cause too much verbosity increase, Csound is a pretty terse language.
Is it a good use of the limited developer time though, I guess that is the real question.
I know that this subject has been brought up before, but I would like to insist: how difficult would it be to add named arguments to csound (maybe csound 7?), so that something like the following would be possible?
Right now we rely on the name of the variables or on comments to understand what is happening.
This would make code much clearer and readable and would make debugging easier. It could even be optional and would work only for opcodes which define names for their arguments.
Opcodes with a great number of inputs would benefit from this greatly. In such cases, when the user needs to set a value for one of these arguments, all arguments which come before must also be defined.