Skip to content

Commit

Permalink
Deprecate fake packages for lookup. (modelica#3290)
Browse files Browse the repository at this point in the history
* Deprecate fake packages for lookup.
Closes modelica#3263
* Update chapters/scoping.tex
* Separate out the deprecated case more clearly, and add explanation for "operator".
* Keep calling it "requirements"
* Apply suggestions from code review
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
  • Loading branch information
HansOlsson committed Feb 9, 2023
1 parent c0361f4 commit 104367d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion chapters/scoping.tex
Expand Up @@ -98,7 +98,12 @@ \subsection{Composite Name Lookup}\label{composite-name-lookup}
\item
If the identifier denotes a class, that class is temporarily flattened (as if instantiating a component without modifiers of this class, see \cref{modification-environment}) and using the enclosing classes of the denoted class.
The rest of the name (e.g., \lstinline!B! or \lstinline!B.C!) is looked up among the declared named elements of the temporary flattened class.
If the class does not satisfy the requirements for a package, the lookup is restricted to encapsulated\indexinline{encapsulated} elements only.
The lookup will only find the element (assuming it exists) in the following cases:
\begin{itemize}
\item If the class is declared as \lstinline!package! or \lstinline!operator! (but not \lstinline!operator record! or \lstinline!operator function!) all elements can be found.
\item An element can be found if it is declared as \lstinline!encapsulated!\indexinline{encapsulated}.
\item A deprecated case is that if the class satisfies the requirements for a \lstinline!package! (without being declared as such), it is still treated as a \lstinline!package!.
\end{itemize}
The class we look inside shall not be partial in a simulation model.
\end{itemize}

Expand All @@ -123,6 +128,12 @@ \subsection{Composite Name Lookup}\label{composite-name-lookup}
\end{lstlisting}
\end{example}

\begin{nonnormative}
Note that an \lstinline!operator! class may only contain declarations of functions and thus fulfills the requirements for a package (see \cref{specialized-classes}).
In practice, the non-deprecated rules imply that we can call \lstinline!Complex.'-'.negate! and \lstinline!Complex.'+'! for the example in \cref{example-of-overloading-for-complex-numbers}.
This requires that \lstinline!operator '-'! and \lstinline!operator function '+'! are declared as \lstinline!encapsulated! as in the example.
\end{nonnormative}


\subsection{Global Name Lookup}\label{global-name-lookup}

Expand Down

0 comments on commit 104367d

Please sign in to comment.