Skip to content

Commit

Permalink
Describe 'encapsulated' and add to index
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Dec 1, 2020
1 parent f3d39b5 commit ef7e263
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions chapters/scoping.tex
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ \section{Static Name Lookup}\label{static-name-lookup}

\subsection{Simple Name Lookup}\label{simple-name-lookup}

When an element, equation, or section is flattened, any simple name
(not composed using dot notation) is first looked up sequentially among
iteration variables (if any; see below), and then looked up sequentially in each
member of the ordered set \emph{of instance scopes (see
\cref{the-class-tree}) corresponding to lexically enclosing classes} until a
match is found or an enclosing class is encapsulated. In the latter case
the lookup stops except for the predefined types, functions and
operators defined in this specification. For these cases the lookup continues in the global scope, where they are defined.
A class declared with the keyword \lstinline!encapsulated!\index{encapsulated@\indexinline{encapsulated}} (see \lstinline[language=grammar]!class-definition! in the grammar) is called an \firstuse{encapsulated} class.
By restricting name lookup inside a restricted class in ways defined in this chapter, the meaning of the class is made independent of where it is placed in a package hierarchy.

When an element, equation, or section is flattened, any simple name (not composed using dot notation) is first looked up sequentially among iteration variables (if any; see below), and then looked up sequentially in each member of the ordered set \emph{of instance scopes (see \cref{the-class-tree}) corresponding to lexically enclosing classes} until a match is found or an enclosing class is encapsulated.
In the latter case the lookup stops except for the predefined types, functions and operators defined in this specification.
For these cases the lookup continues in the global scope, where they are defined.

The iteration variables are the implicitly declared iteration variable(s) if inside
the body of a for-loop, \cref{for-equations-repetitive-equation-structures} and \cref{for-statement},
Expand Down Expand Up @@ -110,14 +108,10 @@ \subsection{Composite Name Lookup}\label{composite-name-lookup}
identifiers of the rest of the name (e.g., B and B.C) must be
classes.
\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 elements only. The class we look inside shall
not be partial in a simulation model.
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\index{encapsulated@\indexinline{encapsulated}} elements only.
The class we look inside shall not be partial in a simulation model.
\end{itemize}

\begin{nonnormative}
Expand Down Expand Up @@ -152,7 +146,9 @@ \subsection{Global Name Lookup}\label{global-name-lookup}
For a name starting with dot, e.g.: \lstinline!.A! (or \lstinline!.A.B!, \lstinline!.A.B.C! etc.) lookup is performed as follows:
\begin{itemize}
\item
The first identifier (\lstinline!A!) is looked up in the global scope. This is possible even if the class is encapsulated and import-clauses are not used for this. If there does not exist a class \lstinline!A! in global scope this is an error.
The first identifier (\lstinline!A!) is looked up in the global scope.
This is possible even if the class is encapsulated\index{encapsulated@\indexinline{encapsulated}} and import-clauses are not used for this.
If there does not exist a class \lstinline!A! in global scope this is an error.
\item
If the name is simple then the class \lstinline!A! is the result of lookup.
\item
Expand Down

0 comments on commit ef7e263

Please sign in to comment.