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

end with non-Integer dimensions #2204

Closed
modelica-trac-importer opened this issue Nov 4, 2018 · 10 comments · Fixed by #2766
Closed

end with non-Integer dimensions #2204

modelica-trac-importer opened this issue Nov 4, 2018 · 10 comments · Fixed by #2766
Labels
enhancement New feature or request
Milestone

Comments

@modelica-trac-importer
Copy link
Collaborator

Reported by perost on 2 Oct 2017 12:32 UTC
10.5.2 defines end as:

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 size(A,i) provided indices to A are a subtype of Integer.

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:

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.


Migrated-From: https://trac.modelica.org/Modelica/ticket/2204

@modelica-trac-importer
Copy link
Collaborator Author

Modified by beutlich on 10 Jan 2018 08:19 UTC

@modelica-trac-importer modelica-trac-importer removed this from the Design93 milestone Nov 4, 2018
@modelica-trac-importer
Copy link
Collaborator Author

Comment by hansolsson on 20 Mar 2018 17:11 UTC
Hans: I think the original intention was to disallow this, but the text failed in that.
We might change to allow it.

Language group:
A separate issue was detected: end is used for product, sum.
An alternative would be
product(A)=product(A[j,k,...] for j, k,...)
sum(A)=sum(A[j,k,...] for j, k,...)
(This is specified - and works for other indexing as well.)

And don't use end in the reduction-variant either.

@HansOlsson HansOlsson added this to the ModelicaSpec3.5 milestone Jan 15, 2019
@HansOlsson HansOlsson added the decided A decision has been made (label added before the spec is changed) label Jan 15, 2019
@HansOlsson HansOlsson added enhancement New feature or request and removed bug Something isn't working decided A decision has been made (label added before the spec is changed) labels May 10, 2019
HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue May 10, 2019
…th non-integer indexing.

Note that the main point of modelica#2204 is not decided as far as I can tell.
HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue May 10, 2019
This is not ideal.
@HansOlsson
Copy link
Collaborator

Note: The current text doesn't specify what happens for "end" for non-integer indexed matrix.
I believe the original intention was to not allow it, and this issue proposes to define it to last element.

There was also a separate issue of not defining product(A) in terms of 1 and end; that was decided.

@henrikt-ma
Copy link
Collaborator

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.

@svorkoetter
Copy link
Collaborator

svorkoetter commented May 13, 2019 via email

@HansOlsson
Copy link
Collaborator

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).

@HansOlsson
Copy link
Collaborator

Agreement.

@eshmoylova
Copy link
Member

Is it universally accepted that for Boolean indices true is the upper bound? Should it be stated explicitly?

@perost
Copy link
Collaborator

perost commented Dec 14, 2020

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

@eshmoylova
Copy link
Member

Thanks. I was looking at 10.5.1.

HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment