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
end with non-Integer dimensions #2204
Comments
Modified by beutlich on 10 Jan 2018 08:19 UTC |
Comment by hansolsson on 20 Mar 2018 17:11 UTC Language group: And don't use end in the reduction-variant either. |
…th non-integer indexing. Note that the main point of modelica#2204 is not decided as far as I can tell.
This is not ideal.
Note: The current text doesn't specify what happens for "end" for non-integer indexed matrix. There was also a separate issue of not defining product(A) in terms of 1 and end; that was decided. |
Perhaps someone could give examples of why one would use In general, I think it is always a good idea to try to avoid relying on ordering of (non-integer) array indices. Defining Besides, if we were to define |
One area I could see this being used is with enumerations as an index type (I believe that's allowed).
For an enumeration type E, the lowest value can already be consistently referred to as E(1), but there is no good way to consistently refer to the highest, so `end` would meet that need.
Furthermore, the specification does state that the values of an enumeration type have an order, defined by their order of declaration.
Stefan
…On Mon, 13 May 2019 00:30:24 -0700 Henrik Tidefelt ***@***.***> wrote:
Perhaps someone could give examples of why one would use `end` with a
non-integer dimension? If there aren't any good examples, I think we
should be careful with giving it a meaning.
In general, I think it is always a good idea to try to avoid relying
on ordering of (non-integer) array indices. Defining `end` in terms
of the ordering would just encourage relying more on the ordering.
Besides, if we were to define `end` to mean the last index in the
ordering, I think that we should at the same time define a way of
referring to the first index. If we don't do the latter, I think
that would be another reason for not doing the former.
--
You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub:
#2204 (comment)
--
Stefan Vorkoetter <svorkoetter@maplesoft.com>
|
The proposal is: The expression end may only appear inside array subscripts, and if used in the i:th subscript of an array expression A it is equivalent to the upper bound of the i:th dimension of A. I would add non-normative text: If indices to A are a subtype of Integer it is equivalent to size(A,i). |
Agreement. |
Is it universally accepted that for Boolean indices true is the upper bound? Should it be stated explicitly? |
It's already stated in 10.1.1 |
Thanks. I was looking at 10.5.1. |
Reported by perost on 2 Oct 2017 12:32 UTC
10.5.2 defines end as:
What about when indices to A are not a subtype of Integer, i.e. Boolean or enumeration? Using size in those cases would be a type error according to 10.5.1, so I would suggest using the upper bound as defined in 10.1.1 instead:
Migrated-From: https://trac.modelica.org/Modelica/ticket/2204
The text was updated successfully, but these errors were encountered: