18887, "bradcray", "Associative arrays with anonymous domains and no curly brackets", "2021-12-19T17:46:20Z"
Should the compiler accept array declarations over anonymous associative domains without requiring curly brackets, like so?
var A1: ["hi", "there"] real;
var A2: [1, 2, 3] real;
var A3: [A2] real;
In more detail: Currently, the compiler accepts array declarations of the form:
var A: [1..n, 1..n] real;
as a shorthand for:
var A: [{1..n, 1..n}] real;
(that is, a 2D array over the anonymous domain {1..n, 1..n}
), primarily as a convenience given that most languages don't have domains and so requiring the curly brackets seems like overkill in the rectangular cases.
It turns out that we also permit the curly brackets to be dropped for associative arrays, such that declarations of the form:
var A: [i1, i2, i3] real;
var B: [i1] real;
(where i1, i2, i3 are of a similar type and not ranges) to mean an associative array over an anonymous domain, like:
var A: [{i1, i2, i3}] real;
var B: [{i1}] real;
or:
const D: domain(i1.type) = {i1, i2, i3};
var A: [D] real;
const D2: domain(i1.type) = {i1};
var B: [D2] real;
This surprised me and seems likely to cause confusion, particularly when the types of the indices are things like an array, a domain, a tuple of ranges or the like; or when the index is a singleton and the user thought they were specifying a domain.
To that end, I'm proposing that we require curly brackets for arrays over anonymous associative domains and curious whether anyone would object to this change.