Skip to content

Commit 934d870

Browse files
committed
Fix punctuation: use commas before and after 'for example'
1 parent f89947b commit 934d870

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/Generics/generics.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ \section{Request Evaluator}\label{request evaluator}
10351035

10361036
\section{Incremental Builds}\label{incremental builds}
10371037
\index{incremental build}
1038-
The request evaluator also records dependencies for incremental compilation. The goal of incremental compilation is to prove which files do not need to be rebuilt, in the least conservative way possible. The quality of an incremental compilation implementation can be judged as follows:\footnote{Credit for this idea goes to David Ungar.}
1038+
The request evaluator also records dependencies for incremental compilation. The goal of incremental compilation is to prove which files do not need to be rebuild, in the least conservative way possible. The quality of an incremental compilation implementation can be judged as follows:\footnote{Credit for this idea goes to David Ungar.}
10391039
\begin{enumerate}
10401040
\item Perform a clean build of all source files in the program, and collect the object files.
10411041
\item Make a change to one or more source files in the input program.
@@ -1553,7 +1553,7 @@ \section{Structural Types}
15531553
\index{concrete metatype type}
15541554
\index{instance type}
15551555
\paragraph{Metatype types}
1556-
Types are values in Swift, and a metatype is the type of a type used as a value. The metatype of a type \texttt{T} is written as \texttt{T.Type}. The type \texttt{T} is the \emph{instance type} of the metatype. For example \texttt{(()~->~()).Type} is the metatype type with the instance type \verb|() -> ()|. This metatype has one value, the function type \verb|() -> ()|.
1556+
Types are values in Swift, and a metatype is the type of a type used as a value. The metatype of a type \texttt{T} is written as \texttt{T.Type}. The type \texttt{T} is the \emph{instance type} of the metatype. For example, \texttt{(()~->~()).Type} is the metatype type with the instance type \verb|() -> ()|. This metatype has one value, the function type \verb|() -> ()|.
15571557

15581558
Metatypes are sometimes referred to as \emph{concrete metatypes}, to distinguish them from \emph{existential metatypes}. Most concrete metatypes are singleton types, where the only value is the instance type itself. One exception is class metatypes for non-final classes; the values of a class metatype include the class type itself, but also all subclasses of the class.
15591559

@@ -1619,7 +1619,7 @@ \section{Abstract Types}
16191619
\paragraph{Parameterized protocol types}
16201620
A parameterized protocol type\footnote{The evolution proposal calls them ``constrained protocol types''; here we're going to use the terminology that appeared in the compiler implementation itself. Perhaps the latter should be renamed to match the evolution proposal at some point.} stores a protocol type together with a list of generic arguments. As a constraint type, it expands to a conformance requirement together with one or more same-type requirements. The same-type requirements constrain the protocol's \emph{primary associated types}, which are declared with a syntax similar to a generic parameter list.
16211621

1622-
The written representation looks like a generic nominal type, except the named declaration is a protocol, for example \texttt{Sequence<Int>}. Full details appear in Section~\ref{protocols}. Parameterized protocol types were introduced in Swift 5.7 \cite{se0346}.
1622+
The written representation looks like a generic nominal type, except the named declaration is a protocol, for example, \texttt{Sequence<Int>}. Full details appear in Section~\ref{protocols}. Parameterized protocol types were introduced in Swift 5.7 \cite{se0346}.
16231623

16241624
\index{existential type}
16251625
\paragraph{Existential types}
@@ -1736,7 +1736,7 @@ \section{Miscellaneous Types}
17361736
typealias MyDictionary = Dictionary
17371737
typealias MyDictionary<Key, Value> = Dictionary<Key, Value>
17381738
\end{Verbatim}
1739-
Unbound generic types are also occasionally useful in diagnostics when you want to print the name of a type declaration only (like \texttt{Outer.Inner}) without the generic parameters of its declared interface type (\texttt{Outer<T>.Inner<U>} for example).
1739+
Unbound generic types are also occasionally useful in diagnostics when you want to print the name of a type declaration only (like \texttt{Outer.Inner}) without the generic parameters of its declared interface type (\texttt{Outer<T>.Inner<U>}, for example).
17401740

17411741
\index{type variable type}
17421742
\index{constraint solver arena}
@@ -1893,7 +1893,7 @@ \section{Source Code Reference}\label{typesourceref}
18931893
\begin{Verbatim}
18941894
FunctionType *funcTy = type->castTo<FunctionType>();
18951895
\end{Verbatim}
1896-
These template methods desugar the type if it is a sugared type, and the casted type can never itself be a sugared type. This is usually what you want; for example if \texttt{type} is the \texttt{Swift.Void} type alias type, then \texttt{type->is<TupleType>()} returns true, because it is for all intents and purposes a tuple (an empty tuple), except when printed in diagnostics.
1896+
These template methods desugar the type if it is a sugared type, and the casted type can never itself be a sugared type. This is usually what you want; for example, if \texttt{type} is the \texttt{Swift.Void} type alias type, then \texttt{type->is<TupleType>()} returns true, because it is for all intents and purposes a tuple (an empty tuple), except when printed in diagnostics.
18971897

18981898
There are also top-level template functions \verb|isa<>|, \verb|dyn_cast<>| and \verb|cast<>| that operate on \texttt{TypeBase *}. Using these with \texttt{Type} is an error; you must explicitly unwrap the pointer with \texttt{getPointer()}. These casts do not desugar, and permit casting to sugared types. This is occasionally useful if you need to handle sugared types differently from canonical types for some reason:
18991899
\begin{Verbatim}
@@ -1938,7 +1938,7 @@ \section{Source Code Reference}\label{typesourceref}
19381938
Type ty = ...;
19391939
visitor.visit(ty);
19401940
\end{Verbatim}
1941-
The \texttt{TypeVisitor} also defines various methods corresponding to abstract base classes in the \texttt{TypeBase} hierarchy, so for example you can override \texttt{visitNominalType()} to handle all nominal types at once.
1941+
The \texttt{TypeVisitor} also defines various methods corresponding to abstract base classes in the \texttt{TypeBase} hierarchy, so, for example, you can override \texttt{visitNominalType()} to handle all nominal types at once.
19421942

19431943
The \texttt{TypeVisitor} preserves information if it receives a sugared type; for example, visiting \texttt{Int?}\ will call \texttt{visitOptionalType()}, while visiting \texttt{Optional<Int>} will call \texttt{visitBoundGenericEnumType()}. In the common situation where the semantics of your operation do not depend on type sugar, you can use the \texttt{CanTypeVisitor} template class instead. Here, the \texttt{visit()} method takes a \texttt{CanType}, so \texttt{Int?}\ will need to be canonicalized to \texttt{Optional<Int>} before being passed in.
19441944

0 commit comments

Comments
 (0)