From ab856a8740b03f9f2cf47edea49b7df54a587e81 Mon Sep 17 00:00:00 2001 From: OLSSON Hans Date: Tue, 15 Dec 2020 22:19:07 +0100 Subject: [PATCH] Allow end for non-integer indexing. Closes #2204 --- chapters/arrays.tex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chapters/arrays.tex b/chapters/arrays.tex index e5cbc47c1..0fdc37bf8 100644 --- a/chapters/arrays.tex +++ b/chapters/arrays.tex @@ -1021,14 +1021,18 @@ \subsection{Indexing with Boolean or Enumeration Values}\label{indexing-with-boo \subsection{Indexing with end}\label{indexing-with-end} -The expression \lstinline!end! may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent -to \lstinline!size(A, $i$)! provided indices to \lstinline!A! are a subtype of \lstinline!Integer!. If used inside nested array subscripts it refers -to the most closely nested array. - +The expression \lstinline!end! may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent to the upper bound of the $i$:th dimension of \lstinline!A!. +If used inside nested array subscripts it refers to the most closely nested array. +\begin{nonnormative} +If indices to \lstinline!A! are a subtype of \lstinline!Integer! it is equivalent to \lstinline!size(A,i)!. +\end{nonnormative} \begin{example} \begin{lstlisting}[language=modelica, escapechar=!] A[end - 1, end] !is! A[size(A,1) - 1, size(A,2)] A[v[end], end] !is! A[v[size(v,1)], size(A,2)] // !\emph{First}! end !\emph{is referring to end of v.}! + +Real B[Boolean]; +B[end] !is! B[true] \end{lstlisting} \end{example}