diff --git a/chapters/functions.tex b/chapters/functions.tex index 7055cd0da..ec512bbc1 100644 --- a/chapters/functions.tex +++ b/chapters/functions.tex @@ -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} diff --git a/chapters/interface.tex b/chapters/interface.tex index 0118f4356..e1d3f60ef 100644 --- a/chapters/interface.tex +++ b/chapters/interface.tex @@ -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} @@ -564,7 +564,7 @@ \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); @@ -572,8 +572,8 @@ \section{Function-Compatibility or Function-Subtyping for Functions}\label{funct 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$