-
Notifications
You must be signed in to change notification settings - Fork 41
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
Type for array subscripting #3410
Comments
I find it unbelievable that the intention of the specification would be to really make them that useless. For example, should users really expect that one cannot assign one enumeration-indexed array to another, or that one cannot pass an enumeration-indexed array in a function call? I suggest that we fill this gap in the specification by making them more useful. In general, it should be a matter of making sure we don't impose unnecessary restriction to integer-indexed arrays. To begin with, I don't see any issues with non-integer indexed arrays in the following contexts:
I'd like to explicitly mention that non-integer indexed arrays are not allowed in:
As we have already noted in recent discussions, some design work is also needed in some cases:
(For array slicing with Anything else one would need to cover to make non-integer indexed arrays first class citizens of Modelica? Any of the above that doesn't would seem hard to implement if it's not already working in tools? |
|
I don't have a major objection for these, but:
I don't see why they should be special, but clearly it relates to the handling of |
Yes, that would be one of the challenges. The current specification handles that by requiring a matrix defined as
I would say that size returning an integer is the only useful one, even if not indexed with integers. If we want to generate all indices for the vector we should have |
Right, scalar exponentiation of matrices should work as long as the two array dimension specifications agree, which should follow naturally from the interpretation as repeated multiplication. It would also provide an interesting way to create the identity matrix for
|
I think we lost focus on the real problem here, which is how to interpret this:
In particular, there has been some confusion about this case:
Maybe we just need to add some clarifications in https://specification.modelica.org/master/arrays.html#array-indexing ? For example, this could say more clearly that the resulting array dimension is always integer-indexed (and avoid the strange use of reduced by):
I suppose the most controversial part is what to say about taking a full slice using the
I propose that taking a full slice preserves the original array dimension so that the above declaration equation does not involve any array dimension coercion. |
Coming from #3395, I also realize that we need the current issue to also cover the following even though it is not exactly array subscripting. I would like us to discuss the possibility of unintentional consequences of just referring to https://specification.modelica.org/master/statements-and-algorithm-sections.html#types-as-iteration-ranges when describing array construction. My gut feeling is that these two are different:
Whatever way we resolve this, I think it would deserve special mention in https://specification.modelica.org/master/arrays.html#array-constructor-with-iterators. |
The specification has integer subscripts (which is the default), but also enumeration and Boolean subscripts https://specification.modelica.org/master/arrays.html#boolean-or-enumeration-indices
The latter two are not well-supported, and looking more closely array declarations explicitly states that:
We could generalize it (to support general subscripting), and then we have the following issues:
Note that enumeration and Boolean subscripts for arrays are not used much. It can be used to define "truth-tables" for 9 and 4-valued logic as in Modelica.Electrical.Digital.Tables; but I don't know many additional uses.
The text was updated successfully, but these errors were encountered: