From 0c684e4eae38e6a6810f6a327c5809f9975abfd9 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Wed, 16 Dec 2020 16:14:58 +0100 Subject: [PATCH] Clarify heterogenous array of records. (#2769) * Clarify heterogenous array of records. Closes #2282 --- chapters/arrays.tex | 7 +++++-- chapters/interface.tex | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/chapters/arrays.tex b/chapters/arrays.tex index e5cbc47c1..c81574910 100644 --- a/chapters/arrays.tex +++ b/chapters/arrays.tex @@ -1,7 +1,10 @@ \chapter{Arrays}\label{arrays} -An array can be regarded as a collection of values, all of the same -type. Modelica arrays can be multidimensional and are ``rectangular'', +A non-record array can be regarded as a collection of type compatible values, \cref{type-compatible-expressions}. +An array of records may contain scalar record values whose elements differ in their dimension sizes, but apart from that they must be of the same type. +Such heterogenous arrays may only be used completely, sliced as specified, or indexed. +An array of arrays must have the same dimension sizes for all of the arrays (with the same exception for records). +Modelica arrays can be multidimensional and are ``rectangular'', which in the case of matrices has the consequence that all rows in a matrix have equal length, and all columns have equal length. diff --git a/chapters/interface.tex b/chapters/interface.tex index a82697e6e..9cd95e46e 100644 --- a/chapters/interface.tex +++ b/chapters/interface.tex @@ -605,6 +605,8 @@ \section{Type Compatible Expressions}\label{type-compatible-expressions} the same named elements. The type compatible expression is a record comprised of named elements that are compatible with the corresponding named elements of both \lstinline!A! and \lstinline!B!. + In an array expression the two records may contain elements with different sizes, but apart from that they must be of compatible types. + That generates a heterogenous array of records, see \cref{array}. \item If \lstinline!A! is an array expression then \lstinline!B! must also be an array expression, and \lstinline!ndims(A)! = \lstinline!ndims(B)!. The type compatible expression is an array expression with elements compatible with the elements of both \lstinline!A! and \lstinline!B!. If both \lstinline!size(A)! and \lstinline!size(B)! are known and \lstinline!size(A)! = \lstinline!size(B)! then this defines the size of the type compatible expression, otherwise the size of the expression is not known until the expression is about to be evaluated. In case of an if-expression the size of the type compatible expression is defined based on the branch selected, and for other cases \lstinline!size(A)! = \lstinline!size(B)! must hold at this point. \item