Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Apply suggestions.

Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
Co-authored-by: Elena Shmoylova <eshmoylova@users.noreply.github.com>
  • Loading branch information
3 people committed May 26, 2021
1 parent 8b7fbc9 commit 7969023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ \subsection{Inheritance of Functions}\label{inheritance-of-functions}

\begin{example}
Demonstrating the variability implications.
Note that functions cannot directly use non-constants in enclosing scopes, so we cannot write \lstinline!input Real x1=x;! directly in \lstinline!foo!.
Note that functions cannot directly use non-constants in enclosing scopes, so we cannot write \lstinline!input Real x1 = x;! directly in \lstinline!foo!.
\begin{lstlisting}[language=modelica]
model M
function foo
input Real x1;
input Real x2=2;
input Real x2 = 2;
output Real y;
algorithm
y:=x1+x2;
y := x1 + x2;
end foo;
Real x=time;
function f1=foo(x1=x);
constant Real z=f1(x2=1); // Illegal since 'x' is seen as argument
constant Real z2=f1(x1=2); // Legal, since 'x1' has a new value.
function f1 = foo(x1 = x);
constant Real z = f1(x2 = 1); // Illegal since 'x' is seen as argument
constant Real z2 = f1(x1 = 2); // Legal, since 'x1' has a new value.
end M;
\end{lstlisting}
\end{example}
Expand Down
8 changes: 4 additions & 4 deletions chapters/interface.tex
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ \section{Function-Compatibility or Function-Subtyping for Functions}\label{funct
constraining interface of the function being redeclared.
\end{itemize}

Note that function-compatibilty does currently not ensure that the function call has the correct variability, and that must then be checked after re-declaration - due the possibility of default arguments with higher variability.
Note that function-compatibility does currently not ensure that the function call has the correct variability, and that must then be checked after re-declaration -- due to the possibility of default arguments with higher variability.
\begin{nonnormative}
Thus any call of a function that is replaceable will need to be checked after redeclarations.
\end{nonnormative}
Expand All @@ -564,16 +564,16 @@ \section{Function-Compatibility or Function-Subtyping for Functions}\label{funct
end UseDriveLine;
Modelica.Mechanics.MultiBody.Interface.Frame_a frame_a;
replaceable function gravity = GravityInterface;
constant Real failed[:]=gravity({1,0,0}); // May fail
constant Real failed[:] = gravity({1, 0, 0}); // May fail
equation
frame_a.f = gravity(frame_a.r0);
// or gravity(position=frame_a.r0);
frame_a.t = zeros(3);
end Body;

model PlanetSimulation
parameter Modelica.Units.SI.Mass mSun=2e30;
function sunGravity = PointMassGravity (m=mSun);
parameter Modelica.Units.SI.Mass mSun = 2e30;
function sunGravity = PointMassGravity (m = mSun);
Body planet1(redeclare function gravity = sunGravity);
Body planet2(redeclare function gravity = PointMassGravity (m=2e30));
$\ldots$
Expand Down

0 comments on commit 7969023

Please sign in to comment.