New array declaration syntax

Thanks! We definitely want to hear from end users on topics like this.

1 Like

I like array[N] matrix[I, J] more otherwise, but as @Bob_Carpenter said, it would be inconsistent with declaring an array of reals etc. Moreover, I think array is neither a keyword in Stan or a reserved keyword, so wouldn’t this change potentially break some old code? So I voted for matrix[I, J][N]. For the type specifiers in function arguments I would like to have

  • matrix[] if matrix[I, J][N] is the variable declaration
  • array[] matrix if array[N] matrix[I, J] is the variable declaration
1 Like

I think we would have array declarations be consistent across all types, I was just using matrix as an example, sorry I should have been clear about that when I made the poll.

Good point about making array a reserved keyword. I’m not sure how big of an issue that’ll be. (It should be possible to not make it a reserved keyword but we’d probably have to mangle the parser a bit.)

4 Likes

Finally got around to reading the whole thread - why didn’t the 2nd poll have `matrix[N][I, J] either? haha, oh well.

I guess OCaml does this, though it’s got to have the most backwards (literally) version I’ve seen - the type int option list is a list of options of ints, like [Some 1, None, Some 2]. But it does seem to be expressive enough for them so far.