Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default array values by init #441

Closed
joachimheintz opened this issue Mar 18, 2015 · 1 comment
Closed

default array values by init #441

joachimheintz opened this issue Mar 18, 2015 · 1 comment
Assignees

Comments

@joachimheintz
Copy link
Contributor

according to the manual, the usage of initalizing an array was first:
tab init isize[, ival]
and the comment is: "The t-variable form was introduced in 5.14 and allocated space for a vector or the given size, initialised to the given value (default value is zero)."

i would like to see this in Csound6 again, so
kArr[] init 3, 1
would result in [1, 1, 1](currently, there is no effect of the second argument)

a two-dimensional array could be filled with inital values like this:
kArr[][] init 3, 2, -1
-> [[-1, -1], [-1, -1], [-1, -1]]

so init should

  1. look for the dimensions of the array on left hand side, and if
  2. there is an extra argument on the right hand side, sompared to the number of dimensions, this argument should be interpreted as default value of the array elements.

so, for a string array, it would be:
S_array[] init 5, "hi"
-> ["hi", "hi", "hi", "hi", "hi"]

@kunstmusik
Copy link
Member

I discussed this with @vlazzarini and @jpffitch and it seems like this may be confusing syntax. Suggested is to use fillarray after using init, and to leave the existing syntax as-is. I think with Csound 7 and array initializers (i.e. myArray:i[] = [1,2,3,4,5]) this won't be such a big issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants