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

Add comments with TODOs after LaTeXML issue is fixed #2882

Merged
merged 4 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,10 @@ \subsubsection{Attributes of Enumeration Types}\label{attributes-of-enumeration-

\subsubsection{Type Conversion of Enumeration Values to String or Integer}\label{type-conversion-of-enumeration-values-to-string-or-integer}

The type conversion function \lstinline!Integer($\mbox{\emph{\textless{}expression of enumeration type\textgreater{}}}$)! returns the ordinal number of the enumeration value \lstinline!E.enumvalue!, to which the expression is evaluated, where $\text{\lstinline!Integer(E.e1)!} = 1$, $\text{\lstinline!Integer(E.en)!} = n$, for an enumeration type \lstinline!E = enumeration(e1, $\ldots$, en)!.
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
The type conversion function \lstinline!Integer($\langle$$\mbox{\emph{expression of enumeration type}}$$\rangle$)! returns the ordinal number of the enumeration value \lstinline!E.enumvalue!, to which the expression is evaluated, where $\text{\lstinline!Integer(E.e1)!} = 1$, $\text{\lstinline!Integer(E.en)!} = n$, for an enumeration type \lstinline!E = enumeration(e1, $\ldots$, en)!.

\lstinline!String(E.enumvalue)! gives the \lstinline!String! representation of the enumeration value.

Expand All @@ -1579,10 +1582,10 @@ \subsubsection{Type Conversion of Integer to Enumeration Values}\label{type-conv
implicitly defined. This function can be used in an expression to
convert an integer value to the corresponding (as described in \cref{type-conversion-of-enumeration-values-to-string-or-integer}) enumeration value.

For an enumeration type named \lstinline!EnumTypeName!, the expression
\lstinline!EnumTypeName(<Integer expression>)! returns the
enumeration value \lstinline!EnumTypeName.e! such that \lstinline!Integer(EnumTypeName.e)! is
equal to the original integer expression.
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
For an enumeration type named \lstinline!EnumTypeName!, the expression \lstinline!EnumTypeName($\langle$$\mbox{\emph{Integer expression}}$$\rangle$)! returns the enumeration value \lstinline!EnumTypeName.e! such that \lstinline!Integer(EnumTypeName.e)! is equal to the original integer expression.

Attempting to convert an integer argument that does not correspond to a
value of the enumeration type is an error.
Expand Down
20 changes: 13 additions & 7 deletions chapters/connectors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -786,26 +786,28 @@ \section{Equation Operators for Overconstrained Connection-Based Equation System

\subsection{Overconstrained Equation Operators for Connection Graphs}\label{overconstrained-equation-operators-for-connection-graphs}

A type or record declaration may have an optional definition of function
\lstinline!equalityConstraint! that shall have the following prototype:
A type or record declaration may have an optional definition of function \lstinline!equalityConstraint! that shall have the following prototype:
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
\begin{lstlisting}[language=modelica]
type Type // overdetermined type
extends <base type>;
extends $\langle$$\mbox{\emph{base type}}$$\rangle$;
function equalityConstraint // non-redundant equality
input Type T1;
input Type T2;
output Real residue[ <n> ];
output Real residue[$n$];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about skipping angles here (and the similar line below). The n here should normally be replaced by a number (such as 3 for quaternions).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we solve this nicely by rephrasing this slightly and placing it before the listing?

The \lstinline!residue! output of the \lstinline!equalityConstraint! function shall have known size, say constant $n$.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like having it as <n>.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the angle bracket construct very pretty in general, but still useful for placeholders in need of a textual description. For something acting as a placeholder for a number, I find it more consistent to use the rather well established use of "meta variables" typeset as math.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the well-established meta-variables? Where are they established?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It strikes me now that the use of n in the listing would actually assume that it is an Integer dimension – is this really the current intention? To me, the current text would actually allow an array indexed by Boolean or enumeration (both of which will result in a constant size, which is the requirement), and I don't see that it would really be a problem to do so. If we want to make it more clear that this is allowed, I suggest this:

Suggested change
output Real residue[$n$];
output Real residue[$\langle$$\mbox{\emph{constant size dimension}}$$\rangle$];

In the text, we could elaborate this further:

The \lstinline!residue! output of the \lstinline!equalityConstraint! function shall have known size, say constant $n$. (That is, $n$ cannot depend on inputs to the function, and the array cannot have flexible size given by colon (\lstinline!:!).)

Copy link
Member

@eshmoylova eshmoylova Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be OK with removing the angled brackets around n. But I feel like we need to open a separate issue to clarify what "known size" means. If we come up with a concise wording we could consider putting that into the angle brackets in the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #2886.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. @HansOlsson, would you then be OK with the resolution to move (with some rephrasing) the sentence introducing n to before the listing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be ok with different variants of that - and I agree with @eshmoylova that it seems best to have a separate issue for that, so resolving, accepting and merging this.

algorithm
residue := $\ldots$;
end equalityConstraint;
end Type;

record Record
< declaration of record fields>
$\langle$$\mbox{\emph{declaration of record fields}}$$\rangle$;
function equalityConstraint // non-redundant equality
input Record R1;
input Record R2;
output Real residue[ <n> ];
output Real residue[$n$];
algorithm
residue := $\ldots$;
end equalityConstraint;
Expand Down Expand Up @@ -875,7 +877,11 @@ \subsection{Overconstrained Equation Operators for Connection Graphs}\label{over
This function can be used at all places where a \lstinline!connect! statement is allowed.

\begin{nonnormative}
E.g., it is not allowed to use this function in a when-clause. This definition shall be used if in a model with connectors \lstinline!A! and \lstinline!B! the overdetermined records \lstinline!A.R! and \lstinline!B.R! are algebraically coupled in the model, e.g., due to \lstinline!B.R = f(A.R!, \textless{}other unknowns\textgreater{}).
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
E.g., it is not allowed to use this function in a when-clause.
This definition shall be used if in a model with connectors \lstinline!A! and \lstinline!B! the overdetermined records \lstinline!A.R! and \lstinline!B.R! are algebraically coupled in the model, e.g., due to \lstinline!B.R = f(A.R, $\langle$$\mbox{\emph{other unknowns}}$$\rangle$)!.
\end{nonnormative}
\end{semantics}
\end{operatordefinition}
Expand Down
13 changes: 8 additions & 5 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ \section{Function Declaration}\label{function-declaration}
\begin{nonnormative}
The structure of a typical function declaration is sketched by
the following schematic function example:
\begin{lstlisting}[language=modelica,escapechar=!]
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
\begin{lstlisting}[language=modelica]
function $\mathit{functionname}$
input TypeI1 in1;
input TypeI2 in2;
Expand All @@ -22,10 +25,10 @@ \section{Function Declaration}\label{function-declaration}
output TypeO2 out2 = $\mathit{defaultExpr}_{2}$;
$\ldots$
protected
!\emph{\textless{}local variables\textgreater{}}!
$\langle$$\mbox{\emph{local variables}}$$\rangle$
$\ldots$
algorithm
!\emph{\textless{}statements\textgreater{}}!
$\langle$$\mbox{\emph{statements}}$$\rangle$
$\ldots$
end $\mathit{functionname}$;
\end{lstlisting}
Expand Down Expand Up @@ -159,7 +162,7 @@ \section{Function as a Specialized Class}\label{function-as-a-specialized-class}
\end{nonnormative}
A function \emph{cannot contain} calls to the Modelica \emph{built-in operators} \lstinline!der!, \lstinline!initial!, \lstinline!terminal!, \lstinline!sample!, \lstinline!pre!, \lstinline!edge!, \lstinline!change!, \lstinline!reinit!, \lstinline!delay!, \lstinline!cardinality!, \lstinline!inStream!, \lstinline!actualStream!, to the operators of the built-in package \lstinline!Connections!, to the operators defined in \cref{synchronous-language-elements} and \cref{state-machines}, and is not allowed to contain when-statements.
\item
The dimension \emph{sizes} not declared with (\lstinline!:!) of each array result or array local variable (i.e., a non-input components) of a function must be either given by the input formal parameters, or given by constant or parameter expressions, or by expressions containing combinations of those (\cref{initialization-and-binding-equations-of-components-in-functions}).
The dimension \emph{sizes} not declared with colon (\lstinline!:!) of each array result or array local variable (i.e., a non-input component) of a function must be either given by the input formal parameters, or given by constant or parameter expressions, or by expressions containing combinations of those (\cref{initialization-and-binding-equations-of-components-in-functions}).
\item
For initialization of local variables of a function see \cref{initialization-and-binding-equations-of-components-in-functions}).
\item
Expand Down Expand Up @@ -202,7 +205,7 @@ \section{Function as a Specialized Class}\label{function-as-a-specialized-class}
\item
A function may have a \lstinline!return! statement in its algorithm section body.
\item
A function allows dimension sizes declared with (\lstinline!:!) to be resized for non-input array variables, see \cref{flexible-array-sizes-and-resizing-of-arrays-in-functions}.
A function allows dimension sizes declared with colon (\lstinline!:!) to be resized for non-input array variables, see \cref{flexible-array-sizes-and-resizing-of-arrays-in-functions}.
\item
A function may be defined in a short function definition to be a
function partial derivative.
Expand Down
7 changes: 5 additions & 2 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,12 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators
\section{Clocked When-Clause}\label{clocked-when-clause}

In addition to the previously discussed conditional when-clause, a \emph{clocked} when-clause\index{clocked!when-clause}\index{when-clause!clocked} is introduced:
\begin{lstlisting}[language=modelica,escapechar=!]
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
\begin{lstlisting}[language=modelica]
when $\mathit{clockExpression}$ then
!\emph{\textless{}clocked equations\textgreater{}}!
$\langle$$\mbox{\emph{clocked equations}}$$\rangle$
$\ldots$
end when;
\end{lstlisting}
Expand Down