diff options
author | Martin Odersky <odersky@gmail.com> | 2004-01-08 15:52:45 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-01-08 15:52:45 +0000 |
commit | d8888a99cf2675e698744d1f21f90cdee42609b1 (patch) | |
tree | 621ef130c1e2d1fd21475f19036a2119cb2a4ba1 /doc/reference/ScalaReference.tex | |
parent | abdb5cc6bb86908c0a8a1d9e9ebd038e08c33964 (diff) | |
download | scala-d8888a99cf2675e698744d1f21f90cdee42609b1.tar.gz scala-d8888a99cf2675e698744d1f21f90cdee42609b1.tar.bz2 scala-d8888a99cf2675e698744d1f21f90cdee42609b1.zip |
*** empty log message ***
Diffstat (limited to 'doc/reference/ScalaReference.tex')
-rw-r--r-- | doc/reference/ScalaReference.tex | 65 |
1 files changed, 19 insertions, 46 deletions
diff --git a/doc/reference/ScalaReference.tex b/doc/reference/ScalaReference.tex index fa5a795b65..c62e0f04b4 100644 --- a/doc/reference/ScalaReference.tex +++ b/doc/reference/ScalaReference.tex @@ -304,7 +304,7 @@ referenced entity in $T$. Type ::= Type1 `=>' Type | `(' [Types] `)' `=>' Type | Type1 - Type1 ::= SimpleType {with SimpleType} [Refinement] + Type1 ::= SimpleType {with SimpleType} SimpleType ::= StableId | SimpleType `#' id | Path `.' type @@ -318,14 +318,12 @@ take type parameters and yield types. A subset of first-order types called {\em value types} represents sets of (first-class) values. Value types are either {\em concrete} or {\em abstract}. Every concrete value type can be represented as a {\em class type}, i.e.\ a -type designator (\sref{sec:type-desig}) that refers to a -class\footnote{We assume that objects and packages also -implicitly define a class (of the same name as the object or package, -but inaccessible to user programs).} (\sref{sec:classes}), -or as a {\em compound type} (\sref{sec:compound-types}) -consisting of class types and possibly -also a refinement (\sref{sec:refinements}) that further constrains the -types of its members. +type designator (\sref{sec:type-desig}) that refers to a +class\footnote{We assume that objects and packages also implicitly +define a class (of the same name as the object or package, but +inaccessible to user programs).} (\sref{sec:classes}), or as a {\em +compound type} (\sref{sec:compound-types}) of class types. +\todo{verify whether operands need to be class types} A shorthand exists for denoting function types (\sref{sec:function-types}). Abstract value types are introduced by @@ -474,25 +472,14 @@ the following types are ill-formed: \label{sec:compound-types} \syntax\begin{lstlisting} - Type ::= SimpleType {with SimpleType} [Refinement] - Refinement ::= `{' [RefineStat {`;' RefineStat}] `}' - RefineStat ::= Dcl - | type TypeDef {`,' TypeDef} - | + Type ::= SimpleType {with SimpleType} \end{lstlisting} -A compound type ~\lstinline@$T_1$ with $\ldots$ with $T_n$ {$R\,$}@~ represents -objects with members as given in the component types $T_1 \commadots -T_n$ and the refinement \lstinline@{$R\,$}@. Each component type $T_i$ must be a -class type and the base class sequence generated by types $T_1 -\commadots T_n$ must be well-formed (\sref{sec:basetypes-wf}). A -refinement \lstinline@{$R\,$}@ contains declarations and type -definitions. Each declaration or definition in a refinement must -override a declaration or definition in one of the component types -$T_1 \commadots T_n$. The usual rules for overriding (\sref{}) -apply. If no refinement is given, the empty refinement is implicitly -added, i.e. ~\lstinline@$T_1$ with $\ldots$ with $T_n$@~ is a shorthand for -~\lstinline@$T_1$ with $\ldots$ with $T_n$ {}@. +A compound type ~\lstinline@$T_1$ with $\ldots$ with $T_n$ {$R\,$}@~ +represents objects with members as given in the component types $T_1 +\commadots T_n$. Each component type $T_i$ must be a class type and +the base class sequence generated by types $T_1 \commadots T_n$ must +be well-formed (\sref{sec:basetypes-wf}). \subsection{Function Types} \label{sec:function-types} @@ -758,10 +745,7 @@ consisting only of package or object selectors and ending in $O$, then ~\lstinline@$O$.this.type $\equiv p$.type@. \item Two compound types are equivalent if their component types are -pairwise equivalent and their refinements are equivalent. Two -refinements are equivalent if they bind the same names and the -modifiers, types and bounds of every declared entity are equivalent in -both refinements. +pairwise equivalent. \item Two method types are equivalent if they have equivalent result types, both have the same number of parameters, and corresponding @@ -938,9 +922,8 @@ the expression is typed and evaluated is if it was \end{lstlisting} A {\em declaration} introduces names and assigns them types. It can -appear as one of the statements of a class definition -(\sref{sec:templates}) or as part of a refinement in a compound -type (\sref{sec:refinements}). +only appear as one of the statements of a class definition +(\sref{sec:templates}). A {\em definition} introduces names that denote terms or types. It can form part of an object or class definition or it can be local to a @@ -2720,13 +2703,7 @@ constructor invocations (of types $S, T_1 \commadots T_n$, say) and $stats$ is a statement sequence containing initializer statements and member definitions (\sref{sec:members}). The type of such an instance creation expression is then the compound type -\lstinline@$S$ with $T_1$ with $\ldots$ with $T_n$ {$R\,$}@, -where \lstinline@{$R\,$}@ is -a refinement (\sref{sec:compound-types}) which declares exactly those -members of $stats$ that override a member of $S$ or $T_1 \commadots -T_n$. \todo{what about methods and overloaded defs?} For this type to -be well-formed, $R$ may not reference types defined in $stats$ which -do not themselves form part of $R$. +\lstinline@$S$ with $T_1$ with $\ldots$ with $T_n$@. The instance creation expression is evaluated by creating a fresh object, which is initialized by evaluating the expression template. @@ -3398,7 +3375,7 @@ Concretely, we distinguish the following kinds of patterns. A {\em wild-card pattern} \_ matches any value. A {\em typed pattern} $\_: T$ matches values of type $T$. The type $T$ may be - a class type or a compound type; it may not contain a refinement (\sref{sec:refinements}). + a class type or a compound type. This pattern matches any non-null value of type $T$. $T$ must conform to the pattern's expected type. A pattern $x:T$ is treated the same way as $x @ (_:T)$ @@ -4260,7 +4237,7 @@ grammar. Type ::= Type1 `=>' Type | `(' [Types] `)' `=>' Type | Type1 - Type1 ::= SimpleType {with SimpleType} [Refinement] + Type1 ::= SimpleType {with SimpleType} SimpleType ::= SimpleType TypeArgs | SimpleType `#' id | StableId @@ -4268,10 +4245,6 @@ grammar. | `(' Type ')' TypeArgs ::= `[' Types `]' Types ::= Type {`,' Type} - Refinement ::= `{' [RefineStat {`;' RefineStat}] `}' - RefineStat ::= Dcl - | type TypeDef {`,' TypeDef} - | Exprs ::= Expr {`,' Expr} Expr ::= Bindings `=>' Expr |