summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/01-lexical-syntax.md60
-rw-r--r--spec/02-identifiers-names-and-scopes.md11
-rw-r--r--spec/03-types.md281
-rw-r--r--spec/04-basic-declarations-and-definitions.md109
-rw-r--r--spec/05-classes-and-objects.md110
-rw-r--r--spec/06-expressions.md245
-rw-r--r--spec/07-implicit-parameters-and-views.md47
-rw-r--r--spec/08-pattern-matching.md62
-rw-r--r--spec/09-top-level-definitions.md14
-rw-r--r--spec/10-xml-expressions-and-patterns.md33
-rw-r--r--spec/11-user-defined-annotations.md5
-rw-r--r--spec/12-the-scala-standard-library.md129
-rw-r--r--spec/13-syntax-summary.md36
-rw-r--r--spec/14-references.md8
-rw-r--r--spec/README.md5
-rw-r--r--spec/index.md2
16 files changed, 497 insertions, 660 deletions
diff --git a/spec/01-lexical-syntax.md b/spec/01-lexical-syntax.md
index ef1f2bf053..4bfef79ac5 100644
--- a/spec/01-lexical-syntax.md
+++ b/spec/01-lexical-syntax.md
@@ -11,7 +11,7 @@ Scala programs are written using the Unicode Basic Multilingual Plane
presently supported. This chapter defines the two modes of Scala's
lexical syntax, the Scala mode and the _XML mode_. If not
otherwise mentioned, the following descriptions of Scala tokens refer
-to _Scala mode_, and literal characters ‘c’ refer to the ASCII fragment
+to _Scala mode_, and literal characters ‘c’ refer to the ASCII fragment
`\u0000` – `\u007F`.
In Scala mode, _Unicode escapes_ are replaced by the corresponding
@@ -29,7 +29,7 @@ but I can't make it work nor can I imagine how this would make sense,
so I removed it for now.
-->
-To construct tokens, characters are distinguished according to the following
+To construct tokens, characters are distinguished according to the following
classes (Unicode general category given in parentheses):
1. Whitespace characters. `\u0020 | \u0009 | \u000D | \u000A`.
@@ -41,13 +41,13 @@ classes (Unicode general category given in parentheses):
1. Parentheses `‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’ `.
1. Delimiter characters ``‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’ ``.
1. Operator characters. These consist of all printable ASCII characters
- `\u0020` - `\u007F` which are in none of the sets above, mathematical
+ `\u0020` - `\u007F` which are in none of the sets above, mathematical
symbols (`Sm`) and other symbols (`So`).
## Identifiers
```ebnf
-op ::= opchar {opchar}
+op ::= opchar {opchar}
varid ::= lower idrest
plainid ::= upper idrest
| varid
@@ -61,14 +61,14 @@ There are three ways to form an identifier. First, an identifier can
start with a letter which can be followed by an arbitrary sequence of
letters and digits. This may be followed by underscore ‘_’
characters and another string composed of either letters and digits or
-of operator characters. Second, an identifier can start with an operator
+of operator characters. Second, an identifier can start with an operator
character followed by an arbitrary sequence of operator characters.
The preceding two forms are called _plain_ identifiers. Finally,
an identifier may also be formed by an arbitrary string between
back-quotes (host systems may impose some restrictions on which
strings are legal for identifiers). The identifier then is composed
of all characters excluding the backquotes themselves.
-
+
As usual, a longest match rule applies. For instance, the string
```scala
@@ -92,8 +92,8 @@ do else extends false final
finally for forSome if implicit
import lazy match new null
object override package private protected
-return sealed super this throw
-trait try true type val
+return sealed super this throw
+trait try true type val
var while with yield
_ : = => <- <: <% >: # @
```
@@ -115,7 +115,6 @@ For instance, the statement `Thread.yield()` is illegal, since
`yield` is a reserved word in Scala. However, here's a
work-around: `` Thread.`yield`() ``
-
## Newline Characters
```ebnf
@@ -134,7 +133,7 @@ The tokens that can terminate a statement are: literals, identifiers
and the following delimiters and reserved words:
```scala
-this null true false return type <xml-start>
+this null true false return type <xml-start>
_ ) ] }
```
@@ -142,8 +141,8 @@ The tokens that can begin a statement are all Scala tokens _except_
the following delimiters and reserved words:
```scala
-catch else extends finally forSome match
-with yield , . ; : = => <- <: <%
+catch else extends finally forSome match
+with yield , . ; : = => <- <: <%
>: # [ ) ] }
```
@@ -169,7 +168,7 @@ Newlines are disabled in:
1. Any regions analyzed in [XML mode](#xml-mode).
Note that the brace characters of `{...}` escapes in XML and
-string literals are not tokens,
+string literals are not tokens,
and therefore do not enclose a region where newlines
are enabled.
@@ -189,14 +188,14 @@ Multiple newline tokens are accepted in the following places (note
that a semicolon in place of the newline would be illegal in every one
of these cases):
-- between the condition of a
+- between the condition of a
[conditional expression](06-expressions.html#conditional-expressions)
or [while loop](06-expressions.html#while-loop-expressions) and the next
following expression,
-- between the enumerators of a
+- between the enumerators of a
[for-comprehension](06-expressions.html#for-comprehensions-and-for-loops)
and the next following expression, and
-- after the initial `type` keyword in a
+- after the initial `type` keyword in a
[type definition or declaration](04-basic-declarations-and-definitions.html#type-declarations-and-type-aliases).
A single new line token is accepted
@@ -300,16 +299,15 @@ illegal).
protected class Data { ... }
```
-
## Literals
There are literals for integer numbers, floating point numbers,
characters, booleans, symbols, strings. The syntax of these literals is in
each case as in Java.
-<!-- TODO
+<!-- TODO
say that we take values from Java, give examples of some lits in
- particular float and double.
+ particular float and double.
-->
```ebnf
@@ -322,11 +320,10 @@ Literal ::= [‘-’] integerLiteral
| ‘null’
```
-
### Integer Literals
```ebnf
-integerLiteral ::= (decimalNumeral | hexNumeral | octalNumeral)
+integerLiteral ::= (decimalNumeral | hexNumeral | octalNumeral)
[‘L’ | ‘l’]
decimalNumeral ::= ‘0’ | nonZeroDigit {digit}
hexNumeral ::= ‘0’ ‘x’ hexDigit {hexDigit}
@@ -356,14 +353,12 @@ is _pt_. The numeric ranges given by these types are:
|`Short` | $-2\^{15}$ to $2\^{15}-1$|
|`Char` | $0$ to $2\^{16}-1$ |
-
### Example
```scala
0 21 0xFFFFFFFF -42L
```
-
### Floating Point Literals
```ebnf
@@ -410,7 +405,6 @@ booleanLiteral ::= ‘true’ | ‘false’
The boolean literals `true` and `false` are
members of type `Boolean`.
-
### Character Literals
```ebnf
@@ -433,7 +427,6 @@ character `\u000A` (line feed) is not a printable
character. One can use instead the escape sequence `'\n'` or
the octal escape `'\12'` ([see here](#escape-sequences)).
-
### String Literals
```ebnf
@@ -446,7 +439,7 @@ characters are either printable unicode character or are described by
[escape sequences](#escape-sequences). If the string literal
contains a double quote character, it must be escaped,
i.e. `"\""`. The value of a string literal is an instance of
-class `String`.
+class `String`.
### Example
@@ -500,17 +493,16 @@ evaluates to
```scala
the present string
-spans three
+spans three
lines.
```
Method `stripMargin` is defined in class
-[scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.StringLike).
+[scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.StringLike).
Because there is a predefined
[implicit conversion](06-expressions.html#implicit-conversions) from `String` to
`StringLike`, the method is applicable to all strings.
-
### Escape Sequences
The following escape sequences are recognized in character and string literals.
@@ -526,7 +518,6 @@ The following escape sequences are recognized in character and string literals.
| `‘\‘ ‘'‘` | `\u0027` | single quote | `'` |
| `‘\‘ ‘\‘` | `\u005c` | backslash | `\` |
-
A character with Unicode between 0 and 255 may also be represented by
an octal escape, i.e. a backslash `'\'` followed by a
sequence of up to three octal characters.
@@ -534,7 +525,6 @@ sequence of up to three octal characters.
It is a compile time error if a backslash character in a character or
string literal does not start a valid escape sequence.
-
### Symbol literals
```ebnf
@@ -557,7 +547,6 @@ caches weak references to `Symbol`s, thus ensuring that
identical symbol literals are equivalent with respect to reference
equality.
-
## Whitespace and Comments
Tokens may be separated by whitespace characters
@@ -572,7 +561,6 @@ but are required to be properly nested. Therefore, a comment like
`/* /* */` will be rejected as having an unterminated
comment.
-
## XML mode
In order to allow literal inclusion of XML fragments, lexical analysis
@@ -589,10 +577,10 @@ brace and immediately followed by a character starting an XML name.
The scanner switches from XML mode to Scala mode if either
-- the XML expression or the XML pattern started by the initial ‘<’ has been
+- the XML expression or the XML pattern started by the initial ‘<’ has been
successfully parsed, or if
-- the parser encounters an embedded Scala expression or pattern and
- forces the Scanner
+- the parser encounters an embedded Scala expression or pattern and
+ forces the Scanner
back to normal mode, until the Scala expression or pattern is
successfully parsed. In this case, since code and XML fragments can be
nested, the parser has to maintain a stack that reflects the nesting
diff --git a/spec/02-identifiers-names-and-scopes.md b/spec/02-identifiers-names-and-scopes.md
index bfb743dbe4..afa97c136c 100644
--- a/spec/02-identifiers-names-and-scopes.md
+++ b/spec/02-identifiers-names-and-scopes.md
@@ -17,14 +17,13 @@ which are collectively called _bindings_.
Bindings of different kinds have a precedence defined on them:
1. Definitions and declarations that are local, inherited, or made
- available by a package clause in the same compilation unit where the
- definition occurs have highest precedence.
+ available by a package clause in the same compilation unit where the
+ definition occurs have highest precedence.
1. Explicit imports have next highest precedence.
1. Wildcard imports have next highest precedence.
1. Definitions made available by a package clause not in the
compilation unit where the definition occurs have lowest precedence.
-
There are two different name spaces, one for [types](03-types.html#types)
and one for [terms](06-expressions.html#expressions). The same name may designate a
type and a term, depending on the context where the name is used.
@@ -33,7 +32,7 @@ A binding has a _scope_ in which the entity defined by a single
name can be accessed using a simple name. Scopes are nested. A binding
in some inner scope _shadows_ bindings of lower precedence in the
same scope as well as bindings of the same or lower precedence in outer
-scopes.
+scopes.
<!-- TODO: either the example, the spec, or the compiler is wrong
@@ -55,7 +54,7 @@ A reference to an unqualified (type- or term-) identifier $x$ is bound
by the unique binding, which
- defines an entity with name $x$ in the same namespace as the identifier, and
-- shadows all other bindings that define entities with name $x$ in that
+- shadows all other bindings that define entities with name $x$ in that
namespace.
It is an error if no such binding exists. If $x$ is bound by an
@@ -70,7 +69,6 @@ the member of the type $T$ of $e$ which has the name $x$ in the same
namespace as the identifier. It is an error if $T$ is not a [value type](03-types.html#value-types).
The type of $e.x$ is the member type of the referenced entity in $T$.
-
### Example
Assume the following two definitions of a objects named `X` in packages `P` and `Q`.
@@ -111,4 +109,3 @@ object A {
println("L20: "+x) // `x' refers to string "abc" here
}}}}}}
```
-
diff --git a/spec/03-types.md b/spec/03-types.md
index 29e6426530..5cfb85e1fc 100644
--- a/spec/03-types.md
+++ b/spec/03-types.md
@@ -11,9 +11,9 @@ chapter: 3
| InfixType [ExistentialClause]
FunctionArgTypes ::= InfixType
| ‘(’ [ ParamType {‘,’ ParamType } ] ‘)’
- ExistentialClause ::= ‘forSome’ ‘{’ ExistentialDcl
+ ExistentialClause ::= ‘forSome’ ‘{’ ExistentialDcl
{semi ExistentialDcl} ‘}’
- ExistentialDcl ::= ‘type’ TypeDcl
+ ExistentialDcl ::= ‘type’ TypeDcl
| ‘val’ ValDcl
InfixType ::= CompoundType {id [nl] CompoundType}
CompoundType ::= AnnotType {‘with’ AnnotType} [Refinement]
@@ -31,7 +31,7 @@ chapter: 3
We distinguish between first-order types and type constructors, which
take type parameters and yield types. A subset of first-order types
called _value types_ represents sets of (first-class) values.
-Value types are either _concrete_ or _abstract_.
+Value types are either _concrete_ or _abstract_.
Every concrete value type can be represented as a _class type_, i.e. a
[type designator](#type-designators) that refers to a
@@ -39,8 +39,8 @@ Every concrete value type can be represented as a _class type_, i.e. a
[compound type](#compound-types) representing an
intersection of types, possibly with a [refinement](#compound-types)
that further constrains the types of its members.
-<!--
-A shorthand exists for denoting [function types](#function-types)
+<!--
+A shorthand exists for denoting [function types](#function-types)
-->
Abstract value types are introduced by [type parameters](04-basic-declarations-and-definitions.html#type-parameters)
and [abstract type bindings](04-basic-declarations-and-definitions.html#type-declarations-and-type-aliases).
@@ -50,20 +50,19 @@ Parentheses in types can be used for grouping.
define a class (of the same name as the object or package, but
inaccessible to user programs).
-Non-value types capture properties of identifiers that
-[are not values](#non-value-types). For example, a
-[type constructor](#type-constructors) does not directly specify a type of
-values. However, when a type constructor is applied to the correct type
-arguments, it yields a first-order type, which may be a value type.
-
-Non-value types are expressed indirectly in Scala. E.g., a method type is
-described by writing down a method signature, which in itself is not a real
-type, although it gives rise to a corresponding [method type](#method-types).
-Type constructors are another example, as one can write
-`type Swap[m[_, _], a,b] = m[b, a]`, but there is no syntax to write
+Non-value types capture properties of identifiers that
+[are not values](#non-value-types). For example, a
+[type constructor](#type-constructors) does not directly specify a type of
+values. However, when a type constructor is applied to the correct type
+arguments, it yields a first-order type, which may be a value type.
+
+Non-value types are expressed indirectly in Scala. E.g., a method type is
+described by writing down a method signature, which in itself is not a real
+type, although it gives rise to a corresponding [method type](#method-types).
+Type constructors are another example, as one can write
+`type Swap[m[_, _], a,b] = m[b, a]`, but there is no syntax to write
the corresponding anonymous type function directly.
-
## Paths
```ebnf
@@ -83,19 +82,18 @@ A path is one of the following.
- The empty path ε (which cannot be written explicitly in user programs).
- $C.$`this`, where $C$ references a class.
The path `this` is taken as a shorthand for $C.$`this` where
- $C$ is the name of the class directly enclosing the reference.
+ $C$ is the name of the class directly enclosing the reference.
- $p.x$ where $p$ is a path and $x$ is a stable member of $p$.
- _Stable members_ are packages or members introduced by object definitions or
+ _Stable members_ are packages or members introduced by object definitions or
by value definitions of [non-volatile types](#volatile-types).
- $C.$`super`$.x$ or $C.$`super`$[M].x$
- where $C$ references a class and $x$ references a
- stable member of the super class or designated parent class $M$ of $C$.
+ where $C$ references a class and $x$ references a
+ stable member of the super class or designated parent class $M$ of $C$.
The prefix `super` is taken as a shorthand for $C.$`super` where
- $C$ is the name of the class directly enclosing the reference.
+ $C$ is the name of the class directly enclosing the reference.
A _stable identifier_ is a path which ends in an identifier.
-
## Value Types
Every value in Scala has a type which is of one of the following
@@ -110,7 +108,7 @@ SimpleType ::= Path ‘.’ type
A singleton type is of the form $p.$`type`, where $p$ is a
path pointing to a value expected to [conform](06-expressions.html#expression-typing)
to `scala.AnyRef`. The type denotes the set of values
-consisting of `null` and the value denoted by $p$.
+consisting of `null` and the value denoted by $p$.
A _stable type_ is either a singleton type or a type which is
declared to be a subtype of trait `scala.Singleton`.
@@ -122,11 +120,11 @@ SimpleType ::= SimpleType ‘#’ id
```
A type projection $T$#$x$ references the type member named
-$x$ of type $T$.
+$x$ of type $T$.
<!--
The following is no longer necessary:
-If $x$ references an abstract type member, then $T$ must be a
+If $x$ references an abstract type member, then $T$ must be a
[stable type](#singleton-types)
-->
@@ -162,8 +160,6 @@ with a type member `Node` and the standard class `scala.Int`,
|scala.Int | scala.type#Int |
|data.maintable.Node | data.maintable.type#Node |
-
-
### Parameterized Types
```ebnf
@@ -172,7 +168,7 @@ TypeArgs ::= ‘[’ Types ‘]’
```
A parameterized type $T[ U_1 , \ldots , U_n ]$ consists of a type
-designator $T$ and type parameters $U_1 , \ldots , U_n$ where
+designator $T$ and type parameters $U_1 , \ldots , U_n$ where
$n \geq 1$. $T$ must refer to a type constructor which takes $n$ type
parameters $a_1 , \ldots , a_n$.
@@ -270,7 +266,6 @@ The following type adds the `@suspendable` annotation to the type `String`:
String @suspendable
```
-
### Compound Types
```ebnf
@@ -283,7 +278,7 @@ RefineStat ::= Dcl
```
A compound type $T_1$ `with` … `with` $T_n \\{ R \\}$
-represents objects with members as given in the component types
+represents objects with members as given in the component types
$T_1 , \ldots , T_n$ and the refinement $\\{ R \\}$. A refinement
$\\{ R \\}$ contains declarations and type definitions.
If a declaration or definition overrides a declaration or definition in
@@ -291,7 +286,7 @@ one of the component types $T_1 , \ldots , T_n$, the usual rules for
[overriding](05-classes-and-objects.html#overriding) apply; otherwise the declaration
or definition is said to be “structural” [^2].
-[^2]: A reference to a structurally defined member (method call or access
+[^2]: A reference to a structurally defined member (method call or access
to a value or variable) may generate binary code that is significantly
slower than an equivalent code to a non-structural member.
@@ -341,7 +336,6 @@ Although `Bird` and `Plane` do not share any parent class other than
refinement with structural declarations to accept any object that declares
a value `callsign` and a `fly` method.
-
### Infix Types
```ebnf
@@ -350,7 +344,7 @@ InfixType ::= CompoundType {id [nl] CompoundType}
An infix type $T_1$ `op` $T_2$ consists of an infix
operator `op` which gets applied to two type operands $T_1$ and
-$T_2$. The type is equivalent to the type application
+$T_2$. The type is equivalent to the type application
`op`$[T_1, T_2]$. The infix operator `op` may be an
arbitrary identifier.
@@ -360,13 +354,13 @@ of a type operator is determined as for term operators: type operators
ending in a colon ‘:’ are right-associative; all other
operators are left-associative.
-In a sequence of consecutive type infix operations
+In a sequence of consecutive type infix operations
$t_0 \, \mathit{op} \, t_1 \, \mathit{op_2} \, \ldots \, \mathit{op_n} \, t_n$,
all operators $\mathit{op}\_1 , \ldots , \mathit{op}\_n$ must have the same
associativity. If they are all left-associative, the sequence is
-interpreted as
+interpreted as
$(\ldots (t_0 \mathit{op_1} t_1) \mathit{op_2} \ldots) \mathit{op_n} t_n$,
-otherwise it is interpreted as
+otherwise it is interpreted as
$t_0 \mathit{op_1} (t_1 \mathit{op_2} ( \ldots \mathit{op_n} t_n) \ldots)$.
### Function Types
@@ -380,25 +374,25 @@ FunctionArgs ::= InfixType
The type $(T_1 , \ldots , T_n) \Rightarrow U$ represents the set of function
values that take arguments of types $T1 , \ldots , Tn$ and yield
results of type $U$. In the case of exactly one argument type
-$T \Rightarrow U$ is a shorthand for $(T) \Rightarrow U$.
+$T \Rightarrow U$ is a shorthand for $(T) \Rightarrow U$.
An argument type of the form $\Rightarrow T$
represents a [call-by-name parameter](04-basic-declarations-and-definitions.html#by-name-parameters) of type $T$.
Function types associate to the right, e.g.
-$S \Rightarrow T \Rightarrow U$ is the same as
+$S \Rightarrow T \Rightarrow U$ is the same as
$S \Rightarrow (T \Rightarrow U)$.
Function types are shorthands for class types that define `apply`
-functions. Specifically, the $n$-ary function type
+functions. Specifically, the $n$-ary function type
$(T_1 , \ldots , T_n) \Rightarrow U$ is a shorthand for the class type
`Function$_n$[T1 , … , $T_n$, U]`. Such class
types are defined in the Scala library for $n$ between 0 and 9 as follows.
```scala
-package scala
+package scala
trait Function_n[-T1 , … , -T$_n$, +R] {
- def apply(x1: T1 , … , x$_n$: T$_n$): R
- override def toString = "<function>"
+ def apply(x1: T1 , … , x$_n$: T$_n$): R
+ override def toString = "<function>"
}
```
@@ -409,28 +403,28 @@ result type and contravariant in their argument types.
```ebnf
Type ::= InfixType ExistentialClauses
-ExistentialClauses ::= ‘forSome’ ‘{’ ExistentialDcl
+ExistentialClauses ::= ‘forSome’ ‘{’ ExistentialDcl
{semi ExistentialDcl} ‘}’
-ExistentialDcl ::= ‘type’ TypeDcl
+ExistentialDcl ::= ‘type’ TypeDcl
| ‘val’ ValDcl
```
An existential type has the form `$T$ forSome { $Q$ }`
-where $Q$ is a sequence of
+where $Q$ is a sequence of
[type declarations](04-basic-declarations-and-definitions.html#type-declarations-and-type-aliases).
-Let
+Let
$t_1[\mathit{tps}\_1] >: L_1 <: U_1 , \ldots , t_n[\mathit{tps}\_n] >: L_n <: U_n$
be the types declared in $Q$ (any of the
type parameter sections `[ $\mathit{tps}_i$ ]` might be missing).
The scope of each type $t_i$ includes the type $T$ and the existential clause
-$Q$.
-The type variables $t_i$ are said to be _bound_ in the type
+$Q$.
+The type variables $t_i$ are said to be _bound_ in the type
`$T$ forSome { $Q$ }`.
Type variables which occur in a type $T$ but which are not bound in $T$ are said
to be _free_ in $T$.
-A _type instance_ of `$T$ forSome { $Q$ }`
+A _type instance_ of `$T$ forSome { $Q$ }`
is a type $\sigma T$ where $\sigma$ is a substitution over $t_1 , \ldots , t_n$
such that, for each $i$, $\sigma L_i <: \sigma t_i <: \sigma U_i$.
The set of values denoted by the existential type `$T$ forSome {$\,Q\,$}`
@@ -457,21 +451,20 @@ is equivalent to
1. An empty quantification can be dropped. E.g.,
`$T$ forSome { }` is equivalent to $T$.
1. An existential type `$T$ forSome { $Q$ }` where $Q$ contains
-a clause `type $t[\mathit{tps}] >: L <: U$` is equivalent
-to the type `$T'$ forSome { $Q$ }` where $T'$ results from $T$ by replacing
+a clause `type $t[\mathit{tps}] >: L <: U$` is equivalent
+to the type `$T'$ forSome { $Q$ }` where $T'$ results from $T$ by replacing
every [covariant occurrence](04-basic-declarations-and-definitions.html#variance-annotations) of $t$ in $T$ by $U$ and by
replacing every contravariant occurrence of $t$ in $T$ by $L$.
-
#### Existential Quantification over Values
As a syntactic convenience, the bindings clause
in an existential type may also contain
-value declarations `val $x$: $T$`.
+value declarations `val $x$: $T$`.
An existential type `$T$ forSome { $Q$; val $x$: $S\,$;$\,Q'$ }`
is treated as a shorthand for the type
-`$T'$ forSome { $Q$; type $t$ <: $S$ with Singleton; $Q'$ }`, where $t$ is a
-fresh type name and $T'$ results from $T$ by replacing every occurrence of
+`$T'$ forSome { $Q$; type $t$ <: $S$ with Singleton; $Q'$ }`, where $t$ is a
+fresh type name and $T'$ results from $T$ by replacing every occurrence of
`$x$.type` with $t$.
#### Placeholder Syntax for Existential Types
@@ -482,17 +475,17 @@ WildcardType ::= ‘_’ TypeBounds
Scala supports a placeholder syntax for existential types.
A _wildcard type_ is of the form `_$\;$>:$\,L\,$<:$\,U$`. Both bound
-clauses may be omitted. If a lower bound clause `>:$\,L$` is missing,
+clauses may be omitted. If a lower bound clause `>:$\,L$` is missing,
`>:$\,$scala.Nothing`
-is assumed. If an upper bound clause `<:$\,U$` is missing,
-`<:$\,$scala.Any` is assumed. A wildcard type is a shorthand for an
-existentially quantified type variable, where the existential quantification is
+is assumed. If an upper bound clause `<:$\,U$` is missing,
+`<:$\,$scala.Any` is assumed. A wildcard type is a shorthand for an
+existentially quantified type variable, where the existential quantification is
implicit.
A wildcard type must appear as type argument of a parameterized type.
-Let $T = p.c[\mathit{targs},T,\mathit{targs}']$ be a parameterized type where
+Let $T = p.c[\mathit{targs},T,\mathit{targs}']$ be a parameterized type where
$\mathit{targs}, \mathit{targs}'$ may be empty and
-$T$ is a wildcard type `_$\;$>:$\,L\,$<:$\,U$`. Then $T$ is equivalent to the
+$T$ is a wildcard type `_$\;$>:$\,L\,$<:$\,U$`. Then $T$ is equivalent to the
existential
type
@@ -500,7 +493,7 @@ type
$p.c[\mathit{targs},t,\mathit{targs}']$ forSome { type $t$ >: $L$ <: $U$ }
```
-where $t$ is some fresh type variable.
+where $t$ is some fresh type variable.
Wildcard types may also appear as parts of [infix types](#infix-types)
, [function types](#function-types),
or [tuple types](#tuple-types).
@@ -562,20 +555,18 @@ List[java.lang.Number] forSome { type T <: java.lang.Number }
which is in turn equivalent (by simplification rules 2 and 3 above) to
`List[java.lang.Number]`.
-
## Non-Value Types
The types explained in the following do not denote sets of values, nor
do they appear explicitly in programs. They are introduced in this
report as the internal types of defined identifiers.
-
### Method Types
-A method type is denoted internally as $(\mathit{Ps})U$, where $(\mathit{Ps})$
+A method type is denoted internally as $(\mathit{Ps})U$, where $(\mathit{Ps})$
is a sequence of parameter names and types $(p_1:T_1 , \ldots , p_n:T_n)$
for some $n \geq 0$ and $U$ is a (value or method) type. This type
-represents named methods that take arguments named $p_1 , \ldots , p_n$
+represents named methods that take arguments named $p_1 , \ldots , p_n$
of types $T_1 , \ldots , T_n$
and that return a result of type $U$.
@@ -594,7 +585,7 @@ corresponding function type.
###### Example
The declarations
-
+
```
def a: Int
def b (x: Int): Boolean
@@ -612,8 +603,8 @@ c: (Int) (String, String) String
### Polymorphic Method Types
A polymorphic method type is denoted internally as `[$\mathit{tps}\,$]$T$` where
-`[$\mathit{tps}\,$]` is a type parameter section
-`[$a_1$ >: $L_1$ <: $U_1 , \ldots , a_n$ >: $L_n$ <: $U_n$]`
+`[$\mathit{tps}\,$]` is a type parameter section
+`[$a_1$ >: $L_1$ <: $U_1 , \ldots , a_n$ >: $L_n$ <: $U_n$]`
for some $n \geq 0$ and $T$ is a
(value or method) type. This type represents named methods that
take type arguments `$S_1 , \ldots , S_n$` which
@@ -640,8 +631,8 @@ union : [A >: Nothing <: Comparable[A]] (x: Set[A], xs: Set[A]) Set[A]
### Type Constructors
A type constructor is represented internally much like a polymorphic method type.
-`[$\pm$ $a_1$ >: $L_1$ <: $U_1 , \ldots , \pm a_n$ >: $L_n$ <: $U_n$] $T$`
-represents a type that is expected by a
+`[$\pm$ $a_1$ >: $L_1$ <: $U_1 , \ldots , \pm a_n$ >: $L_n$ <: $U_n$] $T$`
+represents a type that is expected by a
[type constructor parameter](04-basic-declarations-and-definitions.html#type-parameters) or an
[abstract type constructor binding](04-basic-declarations-and-definitions.html#type-declarations-and-type-aliases) with
the corresponding type parameter clause.
@@ -649,7 +640,7 @@ the corresponding type parameter clause.
###### Example
Consider this fragment of the `Iterable[+X]` class:
-
+
```
trait Iterable[+X] {
def flatMap[newType[+X] <: Iterable[X], S](f: X => newType[S]): newType[S]
@@ -660,7 +651,6 @@ Conceptually, the type constructor `Iterable` is a name for the
anonymous type `[+X] Iterable[X]`, which may be passed to the
`newType` type constructor parameter in `flatMap`.
-
<!-- ### Overloaded Types
More than one values or methods are defined in the same scope with the
@@ -694,7 +684,6 @@ val f = 0
define a function `f} which has type `(x: T)T $\overload$ Int`.
-->
-
## Base Types and Member Definitions
Types of class members depend on the way the members are referenced.
@@ -704,7 +693,6 @@ Central here are three notions, namely:
prefix type $S$,
1. the notion of the set of member bindings of some type $T$.
-
These notions are defined mutually recursively as follows.
1. The set of _base types_ of a type is a set of class types,
@@ -714,25 +702,25 @@ These notions are defined mutually recursively as follows.
`$T_1$ with … with $T_n$ { $R$ }`.
- The base types of an aliased type are the base types of its alias.
- The base types of an abstract type are the base types of its upper bound.
- - The base types of a parameterized type
+ - The base types of a parameterized type
`$C$[$T_1 , \ldots , T_n$]` are the base types
- of type $C$, where every occurrence of a type parameter $a_i$
+ of type $C$, where every occurrence of a type parameter $a_i$
of $C$ has been replaced by the corresponding parameter type $T_i$.
- The base types of a singleton type `$p$.type` are the base types of
the type of $p$.
- - The base types of a compound type
+ - The base types of a compound type
`$T_1$ with $\ldots$ with $T_n$ { $R$ }`
are the _reduced union_ of the base
- classes of all $T_i$'s. This means:
+ classes of all $T_i$'s. This means:
Let the multi-set $\mathscr{S}$ be the multi-set-union of the
base types of all $T_i$'s.
If $\mathscr{S}$ contains several type instances of the same class, say
`$S^i$#$C$[$T^i_1 , \ldots , T^i_n$]` $(i \in I)$, then
- all those instances
+ all those instances
are replaced by one of them which conforms to all
- others. It is an error if no such instance exists. It follows that the
+ others. It is an error if no such instance exists. It follows that the
reduced union, if it exists,
- produces a set of class types, where different types are instances of
+ produces a set of class types, where different types are instances of
different classes.
- The base types of a type selection `$S$#$T$` are
determined as follows. If $T$ is an alias or abstract type, the
@@ -747,26 +735,26 @@ These notions are defined mutually recursively as follows.
makes sense only if the prefix type $S$
has a type instance of class $C$ as a base type, say
`$S'$#$C$[$T_1 , \ldots , T_n$]`. Then we define as follows.
- - If `$S$ = $\epsilon$.type`, then $T$ in $C$ seen from $S$ is
+ - If `$S$ = $\epsilon$.type`, then $T$ in $C$ seen from $S$ is
$T$ itself.
- Otherwise, if $S$ is an existential type `$S'$ forSome { $Q$ }`, and
- $T$ in $C$ seen from $S'$ is $T'$,
+ $T$ in $C$ seen from $S'$ is $T'$,
then $T$ in $C$ seen from $S$ is `$T'$ forSome {$\,Q\,$}`.
- Otherwise, if $T$ is the $i$'th type parameter of some class $D$, then
- - If $S$ has a base type `$D$[$U_1 , \ldots , U_n$]`, for some type
- parameters `[$U_1 , \ldots , U_n$]`, then $T$ in $C$ seen from $S$
+ - If $S$ has a base type `$D$[$U_1 , \ldots , U_n$]`, for some type
+ parameters `[$U_1 , \ldots , U_n$]`, then $T$ in $C$ seen from $S$
is $U_i$.
- Otherwise, if $C$ is defined in a class $C'$, then
$T$ in $C$ seen from $S$ is the same as $T$ in $C'$ seen from $S'$.
- - Otherwise, if $C$ is not defined in another class, then
+ - Otherwise, if $C$ is not defined in another class, then
$T$ in $C$ seen from $S$ is $T$ itself.
- Otherwise, if $T$ is the singleton type `$D$.this.type` for some class $D$
then
- - If $D$ is a subclass of $C$ and $S$ has a type instance of class $D$
+ - If $D$ is a subclass of $C$ and $S$ has a type instance of class $D$
among its base types, then $T$ in $C$ seen from $S$ is $S$.
- Otherwise, if $C$ is defined in a class $C'$, then
$T$ in $C$ seen from $S$ is the same as $T$ in $C'$ seen from $S'$.
- - Otherwise, if $C$ is not defined in another class, then
+ - Otherwise, if $C$ is not defined in another class, then
$T$ in $C$ seen from $S$ is $T$ itself.
- If $T$ is some other type, then the described mapping is performed
to all its type components.
@@ -787,8 +775,6 @@ These notions are defined mutually recursively as follows.
binding $d_T$ of the type `T` in `S`. In that case, we also say
that `S#T` _is defined by_ $d_T$.
-
-
## Relations between types
We define two relations between types.
@@ -798,7 +784,6 @@ We define two relations between types.
|Equivalence |$T \equiv U$ |$T$ and $U$ are interchangeable in all contexts. |
|Conformance |$T <: U$ |Type $T$ conforms to type $U$. |
-
### Equivalence
Equivalence $(\equiv)$ between types is the smallest congruence [^congruence] such that
@@ -812,7 +797,7 @@ the following holds:
consisting only of package or object selectors and ending in $O$, then
`$O$.this.type $\equiv p$.type`.
- Two [compound types](#compound-types) are equivalent if the sequences
- of their component are pairwise equivalent, and occur in the same order, and
+ of their component are pairwise equivalent, and occur in the same order, 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.
@@ -822,43 +807,42 @@ the following holds:
- they have the same number of parameters; and
- corresponding parameters have equivalent types.
Note that the names of parameters do not matter for method type equivalence.
-- Two [polymorphic method types](#polymorphic-method-types) are equivalent if
- they have the same number of type parameters, and, after renaming one set of
+- Two [polymorphic method types](#polymorphic-method-types) are equivalent if
+ they have the same number of type parameters, and, after renaming one set of
type parameters by another, the result types as well as lower and upper bounds
of corresponding type parameters are equivalent.
-- Two [existential types](#existential-types)
+- Two [existential types](#existential-types)
are equivalent if they have the same number of
quantifiers, and, after renaming one list of type quantifiers by
another, the quantified types as well as lower and upper bounds of
corresponding quantifiers are equivalent.
-- Two [type constructors](#type-constructors) are equivalent if they have the
- same number of type parameters, and, after renaming one list of type
- parameters by another, the result types as well as variances, lower and upper
+- Two [type constructors](#type-constructors) are equivalent if they have the
+ same number of type parameters, and, after renaming one list of type
+ parameters by another, the result types as well as variances, lower and upper
bounds of corresponding type parameters are equivalent.
-
[^congruence]: A congruence is an equivalence relation which is closed under formation of contexts
[^implicit]: A method type is implicit if the parameter section that defines it starts with the `implicit` keyword.
### Conformance
-The conformance relation $(<:)$ is the smallest
+The conformance relation $(<:)$ is the smallest
transitive relation that satisfies the following conditions.
- Conformance includes equivalence. If $T \equiv U$ then $T <: U$.
-- For every value type $T$, `scala.Nothing <: $T$ <: scala.Any`.
-- For every type constructor $T$ (with any number of type parameters),
+- For every value type $T$, `scala.Nothing <: $T$ <: scala.Any`.
+- For every type constructor $T$ (with any number of type parameters),
`scala.Nothing <: $T$ <: scala.Any`.
-
-- For every class type $T$ such that `$T$ <: scala.AnyRef` and not
+
+- For every class type $T$ such that `$T$ <: scala.AnyRef` and not
`$T$ <: scala.NotNull` one has `scala.Null <: $T$`.
- A type variable or abstract type $t$ conforms to its upper bound and
- its lower bound conforms to $t$.
+ its lower bound conforms to $t$.
- A class type or parameterized type conforms to any of its base-types.
- A singleton type `$p$.type` conforms to the type of the path $p$.
- A singleton type `$p$.type` conforms to the type `scala.Singleton`.
- A type projection `$T$#$t$` conforms to `$U$#$t$` if $T$ conforms to $U$.
-- A parameterized type `$T$[$T_1$ , … , $T_n$]` conforms to
+- A parameterized type `$T$[$T_1$ , … , $T_n$]` conforms to
`$T$[$U_1$ , … , $U_n$]` if
the following three conditions hold for $i \in \{ 1 , \ldots , n \}$:
1. If the $i$'th type parameter of $T$ is declared covariant, then
@@ -873,63 +857,61 @@ transitive relation that satisfies the following conditions.
binding $d$ of a type or value $x$ in $R$ there exists a member
binding of $x$ in $T$ which subsumes $d$, then $T$ conforms to the
compound type `$U_1$ with $\ldots$ with $U_n$ {$R\,$}`.
-- The existential type `$T$ forSome {$\,Q\,$}` conforms to
+- The existential type `$T$ forSome {$\,Q\,$}` conforms to
$U$ if its [skolemization](#existential-types)
conforms to $U$.
-- The type $T$ conforms to the existential type `$U$ forSome {$\,Q\,$}`
- if $T$ conforms to one of the [type instances](#existential-types)
+- The type $T$ conforms to the existential type `$U$ forSome {$\,Q\,$}`
+ if $T$ conforms to one of the [type instances](#existential-types)
of `$U$ forSome {$\,Q\,$}`.
- If
- $T_i \equiv T'_i$ for $i \in \{ 1 , \ldots , n\}$ and $U$ conforms to $U'$
+ $T_i \equiv T'_i$ for $i \in \{ 1 , \ldots , n\}$ and $U$ conforms to $U'$
then the method type $(p_1:T_1 , \ldots , p_n:T_n) U$ conforms to
$(p'_1:T'_1 , \ldots , p'_n:T'_n) U'$.
- The polymorphic type
- $[a_1 >: L_1 <: U_1 , \ldots , a_n >: L_n <: U_n] T$ conforms to the
+ $[a_1 >: L_1 <: U_1 , \ldots , a_n >: L_n <: U_n] T$ conforms to the
polymorphic type
$[a_1 >: L'_1 <: U'_1 , \ldots , a_n >: L'_n <: U'_n] T'$ if, assuming
- $L'_1 <: a_1 <: U'_1 , \ldots , L'_n <: a_n <: U'_n$
+ $L'_1 <: a_1 <: U'_1 , \ldots , L'_n <: a_n <: U'_n$
one has $T <: T'$ and $L_i <: L'_i$ and $U'_i <: U_i$
for $i \in \{ 1 , \ldots , n \}$.
-- Type constructors $T$ and $T'$ follow a similar discipline. We characterize
+- Type constructors $T$ and $T'$ follow a similar discipline. We characterize
$T$ and $T'$ by their type parameter clauses
$[a_1 , \ldots , a_n]$ and
- $[a_1' , \ldots , a_n']$, where an $a_i$ or $a_i'$ may include a variance
- annotation, a higher-order type parameter clause, and bounds. Then, $T$
- conforms to $T'$ if any list $[t_1 , \ldots , t_n]$ -- with declared
- variances, bounds and higher-order type parameter clauses -- of valid type
- arguments for $T'$ is also a valid list of type arguments for $T$ and
- $T[t_1 , \ldots , t_n] <: T'[t_1 , \ldots , t_n]$. Note that this entails
+ $[a_1' , \ldots , a_n']$, where an $a_i$ or $a_i'$ may include a variance
+ annotation, a higher-order type parameter clause, and bounds. Then, $T$
+ conforms to $T'$ if any list $[t_1 , \ldots , t_n]$ -- with declared
+ variances, bounds and higher-order type parameter clauses -- of valid type
+ arguments for $T'$ is also a valid list of type arguments for $T$ and
+ $T[t_1 , \ldots , t_n] <: T'[t_1 , \ldots , t_n]$. Note that this entails
that:
- - The bounds on $a_i$ must be weaker than the corresponding bounds declared
- for $a'_i$.
- - The variance of $a_i$ must match the variance of $a'_i$, where covariance
+ - The bounds on $a_i$ must be weaker than the corresponding bounds declared
+ for $a'_i$.
+ - The variance of $a_i$ must match the variance of $a'_i$, where covariance
matches covariance, contravariance matches contravariance and any variance
matches invariance.
- Recursively, these restrictions apply to the corresponding higher-order
type parameter clauses of $a_i$ and $a'_i$.
-
A declaration or definition in some compound type of class type $C$
_subsumes_ another declaration of the same name in some compound type or class
type $C'$, if one of the following holds.
-- A value declaration or definition that defines a name $x$ with type $T$
- subsumes a value or method declaration that defines $x$ with type $T'$, provided
+- A value declaration or definition that defines a name $x$ with type $T$
+ subsumes a value or method declaration that defines $x$ with type $T'$, provided
$T <: T'$.
-- A method declaration or definition that defines a name $x$ with type $T$
- subsumes a method declaration that defines $x$ with type $T'$, provided
+- A method declaration or definition that defines a name $x$ with type $T$
+ subsumes a method declaration that defines $x$ with type $T'$, provided
$T <: T'$.
- A type alias
- `type $t$[$T_1$ , … , $T_n$] = $T$` subsumes a type alias
- `type $t$[$T_1$ , … , $T_n$] = $T'$` if $T \equiv T'$.
+ `type $t$[$T_1$ , … , $T_n$] = $T$` subsumes a type alias
+ `type $t$[$T_1$ , … , $T_n$] = $T'$` if $T \equiv T'$.
- A type declaration `type $t$[$T_1$ , … , $T_n$] >: $L$ <: $U$` subsumes
- a type declaration `type $t$[$T_1$ , … , $T_n$] >: $L'$ <: $U'$` if
+ a type declaration `type $t$[$T_1$ , … , $T_n$] >: $L'$ <: $U'$` if
$L' <: L$ and $U <: U'$.
- A type or class definition that binds a type name $t$ subsumes an abstract
type declaration `type t[$T_1$ , … , $T_n$] >: L <: U` if
$L <: t <: U$.
-
The $(<:)$ relation forms pre-order between types,
i.e. it is transitive and reflexive. _least upper bounds_ and
_greatest lower bounds_ of a set of types
@@ -961,23 +943,20 @@ greatest lower of `A` and `B`. If there are several
least upper bounds or greatest lower bounds, the Scala compiler is
free to pick any one of them.
-
[^4]: The current Scala compiler limits the nesting level
of parameterization in such bounds to be at most two deeper than the
maximum nesting level of the operand types
-
-
### Weak Conformance
-In some situations Scala uses a more general conformance relation. A
-type $S$ _weakly conforms_
+In some situations Scala uses a more general conformance relation. A
+type $S$ _weakly conforms_
to a type $T$, written $S <:_w
T$, if $S <: T$ or both $S$ and $T$ are primitive number types
and $S$ precedes $T$ in the following ordering.
```scala
-Byte $<:_w$ Short
+Byte $<:_w$ Short
Short $<:_w$ Int
Char $<:_w$ Int
Int $<:_w$ Long
@@ -988,14 +967,13 @@ Float $<:_w$ Double
A _weak least upper bound_ is a least upper bound with respect to
weak conformance.
-
## Volatile Types
-Type volatility approximates the possibility that a type parameter or abstract
+Type volatility approximates the possibility that a type parameter or abstract
type instance
-of a type does not have any non-null values. A value member of a volatile type
+of a type does not have any non-null values. A value member of a volatile type
cannot appear in a [path](#paths).
-
+
A type is _volatile_ if it falls into one of four categories:
A compound type `$T_1$ with … with $T_n$ {$R\,$}`
@@ -1007,14 +985,13 @@ is volatile if one of the following two conditions hold.
to the compound type, or
1. one of $T_1 , \ldots , T_n$ is a singleton type.
-
Here, a type $S$ _contributes an abstract member_ to a type $T$ if
$S$ contains an abstract member that is also a member of $T$.
A refinement $R$ contributes an abstract member to a type $T$ if $R$
contains an abstract declaration which is also a member of $T$.
A type designator is volatile if it is an alias of a volatile type, or
-if it designates a type parameter or abstract type that has a volatile type as
+if it designates a type parameter or abstract type that has a volatile type as
its upper bound.
A singleton type `$p$.type` is volatile, if the underlying
@@ -1023,7 +1000,6 @@ type of path $p$ is volatile.
An existential type `$T$ forSome {$\,Q\,$}` is volatile if
$T$ is volatile.
-
## Type Erasure
A type is called _generic_ if it contains type arguments or type variables.
@@ -1036,20 +1012,19 @@ The erasure mapping is defined as follows.
- The erasure of the parameterized type `scala.Array$[T_1]$` is
`scala.Array$[|T_1|]$`.
- The erasure of every other parameterized type $T[T_1 , \ldots , T_n]$ is $|T|$.
-- The erasure of a singleton type `$p$.type` is the
+- The erasure of a singleton type `$p$.type` is the
erasure of the type of $p$.
- The erasure of a type projection `$T$#$x$` is `|$T$|#$x$`.
-- The erasure of a compound type
- `$T_1$ with $\ldots$ with $T_n$ {$R\,$}` is the erasure of the intersection
+- The erasure of a compound type
+ `$T_1$ with $\ldots$ with $T_n$ {$R\,$}` is the erasure of the intersection
dominator of $T_1 , \ldots , T_n$.
- The erasure of an existential type `$T$ forSome {$\,Q\,$}` is $|T|$.
The _intersection dominator_ of a list of types $T_1 , \ldots , T_n$ is computed
as follows.
-Let $T_{i_1} , \ldots , T_{i_m}$ be the subsequence of types $T_i$
-which are not supertypes of some other type $T_j$.
+Let $T_{i_1} , \ldots , T_{i_m}$ be the subsequence of types $T_i$
+which are not supertypes of some other type $T_j$.
If this subsequence contains a type designator $T_c$ that refers to a class
-which is not a trait,
+which is not a trait,
the intersection dominator is $T_c$. Otherwise, the intersection
dominator is the first element of the subsequence, $T_{i_1}$.
-
diff --git a/spec/04-basic-declarations-and-definitions.md b/spec/04-basic-declarations-and-definitions.md
index 358a4765ff..ed7e4c625e 100644
--- a/spec/04-basic-declarations-and-definitions.md
+++ b/spec/04-basic-declarations-and-definitions.md
@@ -6,7 +6,6 @@ chapter: 4
# Basic Declarations and Definitions
-
```ebnf
Dcl ::= ‘val’ ValDcl
| ‘var’ VarDcl
@@ -40,7 +39,6 @@ between and including $s_i$ and $s_j$,
- $s_k$ cannot be a variable definition.
- If $s_k$ is a value definition, it must be lazy.
-
<!--
Every basic definition may introduce several defined names, separated
by commas. These are expanded according to the following scheme:
@@ -79,7 +77,6 @@ additional parts in the definition, then those parts are implicitly
copied from the next subsequent sequence element which consists of
more than just a defined name and parameters. Examples:
-
- []
The variable declaration `var x, y: Int`
expands to `var x: Int; var y: Int`.
@@ -98,14 +95,12 @@ case object Blue extends Color .
```
-->
-
-
## Value Declarations and Definitions
```ebnf
Dcl ::= ‘val’ ValDcl
ValDcl ::= ids ‘:’ Type
-PatVarDef ::= ‘val’ PatDef
+PatVarDef ::= ‘val’ PatDef
PatDef ::= Pattern2 {‘,’ Pattern2} [‘:’ Type] ‘=’ Expr
ids ::= id {‘,’ id}
```
@@ -114,10 +109,10 @@ A value declaration `val $x$: $T$` introduces $x$ as a name of a value of
type $T$.
A value definition `val $x$: $T$ = $e$` defines $x$ as a
-name of the value that results from the evaluation of $e$.
+name of the value that results from the evaluation of $e$.
If the value definition is not recursive, the type
$T$ may be omitted, in which case the [packed type](06-expressions.html#expression-typing) of
-expression $e$ is assumed. If a type $T$ is given, then $e$ is expected to
+expression $e$ is assumed. If a type $T$ is given, then $e$ is expected to
conform to it.
Evaluation of the value definition implies evaluation of its
@@ -187,17 +182,15 @@ val x = x$\$$._1
val xs = x$\$$._2
```
-
The name of any declared or defined value may not end in `_=`.
-A value declaration `val $x_1 , \ldots , x_n$: $T$` is a shorthand for the
+A value declaration `val $x_1 , \ldots , x_n$: $T$` is a shorthand for the
sequence of value declarations `val $x_1$: $T$; ...; val $x_n$: $T$`.
-A value definition `val $p_1 , \ldots , p_n$ = $e$` is a shorthand for the
+A value definition `val $p_1 , \ldots , p_n$ = $e$` is a shorthand for the
sequence of value definitions `val $p_1$ = $e$; ...; val $p_n$ = $e$`.
-A value definition `val $p_1 , \ldots , p_n: T$ = $e$` is a shorthand for the
+A value definition `val $p_1 , \ldots , p_n: T$ = $e$` is a shorthand for the
sequence of value definitions `val $p_1: T$ = $e$; ...; val $p_n: T$ = $e$`.
-
## Variable Declarations and Definitions
```ebnf
@@ -212,7 +205,7 @@ A variable declaration `var $x$: $T$` is equivalent to the declarations
of both a _getter function_ $x$ *and* a _setter function_ `$x$_=`:
```scala
-def $x$: $T$
+def $x$: $T$
def $x$_= ($y$: $T$): Unit
```
@@ -222,13 +215,13 @@ using a variable definition, or by defining the corresponding setter and getter
A variable definition `var $x$: $T$ = $e$` introduces a
mutable variable with type $T$ and initial value as given by the
expression $e$. The type $T$ can be omitted, in which case the type of
-$e$ is assumed. If $T$ is given, then $e$ is expected to
+$e$ is assumed. If $T$ is given, then $e$ is expected to
[conform to it](06-expressions.html#expression-typing).
Variable definitions can alternatively have a [pattern](08-pattern-matching.html#patterns)
as left-hand side. A variable definition
`var $p$ = $e$` where $p$ is a pattern other
-than a simple name or a name followed by a colon and a type is expanded in the same way
+than a simple name or a name followed by a colon and a type is expanded in the same way
as a [value definition](#value-declarations-and-definitions)
`val $p$ = $e$`, except that
the free names in $p$ are introduced as mutable variables, not values.
@@ -249,7 +242,6 @@ The default value depends on the type $T$ as follows:
|`()` | `Unit` |
|`null` | all other types |
-
When they occur as members of a template, both forms of variable
definition also introduce a getter function $x$ which returns the
value currently assigned to the variable, as well as a setter function
@@ -291,13 +283,12 @@ d.hours = 8; d.minutes = 30; d.seconds = 0
d.hours = 25 // throws a DateError exception
```
-
-A variable declaration `var $x_1 , \ldots , x_n$: $T$` is a shorthand for the
+A variable declaration `var $x_1 , \ldots , x_n$: $T$` is a shorthand for the
sequence of variable declarations `var $x_1$: $T$; ...; var $x_n$: $T$`.
-A variable definition `var $x_1 , \ldots , x_n$ = $e$` is a shorthand for the
+A variable definition `var $x_1 , \ldots , x_n$ = $e$` is a shorthand for the
sequence of variable definitions `var $x_1$ = $e$; ...; var $x_n$ = $e$`.
-A variable definition `var $x_1 , \ldots , x_n: T$ = $e$` is a shorthand for
-the sequence of variable definitions
+A variable definition `var $x_1 , \ldots , x_n: T$ = $e$` is a shorthand for
+the sequence of variable definitions
`var $x_1: T$ = $e$; ...; var $x_n: T$ = $e$`.
## Type Declarations and Type Aliases
@@ -341,12 +332,12 @@ have a type parameter clause, e.g. `type $t$[$\mathit{tps}\,$] = $T$`. The scop
of a type parameter extends over the right hand side $T$ and the
type parameter clause $\mathit{tps}$ itself.
-The scope rules for [definitions](#basic-declarations-and-definitions)
+The scope rules for [definitions](#basic-declarations-and-definitions)
and [type parameters](#function-declarations-and-definitions)
make it possible that a type name appears in its
own bound or in its right-hand side. However, it is a static error if
a type alias refers recursively to the defined type constructor itself.
-That is, the type $T$ in a type alias `type $t$[$\mathit{tps}\,$] = $T$` may not
+That is, the type $T$ in a type alias `type $t$[$\mathit{tps}\,$] = $T$` may not
refer directly or indirectly to the name $t$. It is also an error if
an abstract type is directly or indirectly its own upper or lower bound.
@@ -400,7 +391,6 @@ As a consequence, for any two types $S$ and $T$, the type
val x: Pair[Int, String] = new Pair(1, "abc")
```
-
## Type Parameters
```ebnf
@@ -413,7 +403,7 @@ Type parameters appear in type definitions, class definitions, and
function definitions. In this section we consider only type parameter
definitions with lower bounds `>: $L$` and upper bounds
`<: $U$` whereas a discussion of context bounds
-`: $U$` and view bounds `<% $U$`
+`: $U$` and view bounds `<% $U$`
is deferred to [here](07-implicit-parameters-and-views.html#context-bounds-and-view-bounds).
The most general form of a first-order type parameter is
@@ -464,7 +454,6 @@ The following type parameter clauses are illegal:
// not conform to upper bound `B'.
```
-
## Variance Annotations
Variance annotations indicate how instances of parameterized types
@@ -475,17 +464,17 @@ missing variance indication indicates an invariant dependency.
A variance annotation constrains the way the annotated type variable
may appear in the type or class which binds the type parameter. In a
-type definition `type $T$[$\mathit{tps}\,$] = $S$`, or a type
+type definition `type $T$[$\mathit{tps}\,$] = $S$`, or a type
declaration `type $T$[$\mathit{tps}\,$] >: $L$ <: $U$` type parameters labeled
‘+’ must only appear in covariant position whereas
type parameters labeled ‘-’ must only appear in contravariant
position. Analogously, for a class definition
-`class $C$[$\mathit{tps}\,$]($\mathit{ps}\,$) extends $T$ { $x$: $S$ => ...}`,
+`class $C$[$\mathit{tps}\,$]($\mathit{ps}\,$) extends $T$ { $x$: $S$ => ...}`,
type parameters labeled
‘+’ must only appear in covariant position in the
self type $S$ and the template $T$, whereas type
parameters labeled ‘-’ must only appear in contravariant
-position.
+position.
The variance position of a type parameter in a type or template is
defined as follows. Let the opposite of covariance be contravariance,
@@ -493,11 +482,11 @@ and the opposite of invariance be itself. The top-level of the type
or template is always in covariant position. The variance position
changes at the following constructs.
-- The variance position of a method parameter is the opposite of the
+- The variance position of a method parameter is the opposite of the
variance position of the enclosing parameter clause.
- The variance position of a type parameter is the opposite of the
variance position of the enclosing type parameter clause.
-- The variance position of the lower bound of a type declaration or type parameter
+- The variance position of the lower bound of a type declaration or type parameter
is the opposite of the variance position of the type declaration or parameter.
- The type of a mutable variable is always in invariant position.
- The right-hand side of a type alias is always in invariant position.
@@ -508,11 +497,11 @@ changes at the following constructs.
contravariant, the variance position of $T$ is the opposite of
the variance position of the enclosing type `$S$[$\ldots T \ldots$ ]`.
-<!-- TODO: handle type aliases -->
+<!-- TODO: handle type aliases -->
-References to the type parameters in
+References to the type parameters in
[object-private or object-protected values, types, variables, or methods](05-classes-and-objects.html#modifiers) of the class are not
-checked for their variance position. In these members the type parameter may
+checked for their variance position. In these members the type parameter may
appear anywhere without restricting its legal variance annotations.
###### Example
@@ -588,22 +577,21 @@ That is, a
channel on which one can write any object can substitute for a channel
on which one can write only strings.
-
## Function Declarations and Definitions
```ebnf
Dcl ::= ‘def’ FunDcl
FunDcl ::= FunSig ‘:’ Type
Def ::= ‘def’ FunDef
-FunDef ::= FunSig [‘:’ Type] ‘=’ Expr
+FunDef ::= FunSig [‘:’ Type] ‘=’ Expr
FunSig ::= id [FunTypeParamClause] ParamClauses
-FunTypeParamClause ::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
+FunTypeParamClause ::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
ParamClauses ::= {ParamClause} [[nl] ‘(’ ‘implicit’ Params ‘)’]
-ParamClause ::= [nl] ‘(’ [Params] ‘)’}
+ParamClause ::= [nl] ‘(’ [Params] ‘)’}
Params ::= Param {‘,’ Param}
Param ::= {Annotation} id [‘:’ ParamType] [‘=’ Expr]
-ParamType ::= Type
- | ‘=>’ Type
+ParamType ::= Type
+ | ‘=>’ Type
| Type ‘*’
```
@@ -624,8 +612,8 @@ result type, if one is given. If the function definition is not
recursive, the result type may be omitted, in which case it is
determined from the packed type of the function body.
-A type parameter clause $\mathit{tps}$ consists of one or more
-[type declarations](#type-declarations-and-type-aliases), which introduce type
+A type parameter clause $\mathit{tps}$ consists of one or more
+[type declarations](#type-declarations-and-type-aliases), which introduce type
parameters, possibly with bounds. The scope of a type parameter includes
the whole signature, including any of the type parameter bounds as
well as the function body, if it is present.
@@ -647,7 +635,7 @@ declaration. These methods are parametrized by the type parameter clause
The `$f\$$default$\$$n` methods are inaccessible for
user programs.
-The scope of a formal value parameter name $x$ comprises all subsequent
+The scope of a formal value parameter name $x$ comprises all subsequent
parameter clauses, as well as the method return type and the function body, if
they are given. Both type parameter names and value parameter names must
be pairwise distinct.
@@ -669,10 +657,8 @@ def compare$\$$default$\$$1[T]: Int = 0
def compare$\$$default$\$$2[T](a: T): T = a
```
-
### By-Name Parameters
-
```ebnf
ParamType ::= ‘=>’ Type
```
@@ -687,7 +673,7 @@ function. That is, the argument is evaluated using _call-by-name_.
The by-name modifier is disallowed for parameters of classes that
carry a `val` or `var` prefix, including parameters of case
classes for which a `val` prefix is implicitly generated. The
-by-name modifier is also disallowed for
+by-name modifier is also disallowed for
[implicit parameters](07-implicit-parameters-and-views.html#implicit-parameters).
###### Example
@@ -700,7 +686,6 @@ def whileLoop (cond: => Boolean) (stat: => Unit): Unit
indicates that both parameters of `whileLoop` are evaluated using
call-by-name.
-
### Repeated Parameters
```ebnf
@@ -712,17 +697,17 @@ The last value parameter of a parameter section may be suffixed by
_repeated_ parameter inside the method is then the sequence type
`scala.Seq[$T$]`. Methods with repeated parameters
`$T$*` take a variable number of arguments of type $T$.
-That is, if a method $m$ with type
-`($p_1:T_1 , \ldots , p_n:T_n, p_s:S$*)$U$` is applied to arguments
-$(e_1 , \ldots , e_k)$ where $k \geq n$, then $m$ is taken in that application
-to have type $(p_1:T_1 , \ldots , p_n:T_n, p_s:S , \ldots , p_{s'}S)U$, with
+That is, if a method $m$ with type
+`($p_1:T_1 , \ldots , p_n:T_n, p_s:S$*)$U$` is applied to arguments
+$(e_1 , \ldots , e_k)$ where $k \geq n$, then $m$ is taken in that application
+to have type $(p_1:T_1 , \ldots , p_n:T_n, p_s:S , \ldots , p_{s'}S)U$, with
$k - n$ occurrences of type
-$S$ where any parameter names beyond $p_s$ are fresh. The only exception to
+$S$ where any parameter names beyond $p_s$ are fresh. The only exception to
this rule is if the last argument is
marked to be a _sequence argument_ via a `_*` type
annotation. If $m$ above is applied to arguments
`($e_1 , \ldots , e_n, e'$: _*)`, then the type of $m$ in
-that application is taken to be
+that application is taken to be
`($p_1:T_1, \ldots , p_n:T_n,p_{s}:$scala.Seq[$S$])`.
It is not allowed to define any default arguments in a parameter section
@@ -768,7 +753,6 @@ the result `6`:
sum(xs: _*)
```
-
### Procedures
```ebnf
@@ -777,7 +761,7 @@ FunDef ::= FunSig [nl] ‘{’ Block ‘}’
```
Special syntax exists for procedures, i.e. functions that return the
-`Unit` value `()`.
+`Unit` value `()`.
A procedure declaration is a function declaration where the result type
is omitted. The result type is then implicitly completed to the
`Unit` type. E.g., `def $f$($\mathit{ps}$)` is equivalent to
@@ -811,7 +795,6 @@ object Terminal extends Writer {
}
```
-
### Method Return Type Inference
A class member definition $m$ that overrides some other function $m'$
@@ -838,8 +821,6 @@ class C extends I {
Here, it is OK to leave out the result type of `factorial`
in `C`, even though the method is recursive.
-
-
<!-- ## Overloaded Definitions
\label{sec:overloaded-defs}
\todo{change}
@@ -862,12 +843,12 @@ $T_j$ have the same erasure (\sref{sec:erasure}).
```ebnf
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
ImportExpr ::= StableId ‘.’ (id | ‘_’ | ImportSelectors)
-ImportSelectors ::= ‘{’ {ImportSelector ‘,’}
+ImportSelectors ::= ‘{’ {ImportSelector ‘,’}
(ImportSelector | ‘_’) ‘}’
ImportSelector ::= id [‘=>’ id | ‘=>’ ‘_’]
```
-An import clause has the form `import $p$.$I$` where $p$ is a
+An import clause has the form `import $p$.$I$` where $p$ is a
[stable identifier](03-types.html#paths) and $I$ is an import expression.
The import expression determines a set of names of importable members of $p$
which are made available without qualification. A member $m$ of $p$ is
@@ -875,7 +856,7 @@ _importable_ if it is not [object-private](05-classes-and-objects.html#modifiers
The most general form of an import expression is a list of _import selectors_
```scala
-{ $x_1$ => $y_1 , \ldots , x_n$ => $y_n$, _ }
+{ $x_1$ => $y_1 , \ldots , x_n$ => $y_n$, _ }
```
for $n \geq 0$, where the final wildcard `‘_’` may be absent. It
@@ -913,13 +894,13 @@ identifier or wildcard. The import clause `import $p$.$x$` is
equivalent to `import $p$.{$x\,$}`, i.e. it makes available without
qualification the member $x$ of $p$. The import clause
`import $p$._` is equivalent to
-`import $p$.{_}`,
+`import $p$.{_}`,
i.e. it makes available without qualification all members of $p$
(this is analogous to `import $p$.*` in Java).
An import clause with multiple import expressions
`import $p_1$.$I_1 , \ldots , p_n$.$I_n$` is interpreted as a
-sequence of import clauses
+sequence of import clauses
`import $p_1$.$I_1$; $\ldots$; import $p_n$.$I_n$`.
###### Example
diff --git a/spec/05-classes-and-objects.md b/spec/05-classes-and-objects.md
index 429f0b75bc..6ac4c8fdcf 100644
--- a/spec/05-classes-and-objects.md
+++ b/spec/05-classes-and-objects.md
@@ -15,7 +15,6 @@ TmplDef ::= [`case'] `class' ClassDef
[Classes](#class-definitions) and [objects](#object-definitions)
are both defined in terms of _templates_.
-
## Templates
```ebnf
@@ -31,8 +30,8 @@ SelfType ::= id [`:' Type] `=>'
A template defines the type signature, behavior and initial state of a
trait or class of objects or of a single object. Templates form part of
instance creation expressions, class definitions, and object
-definitions. A template
-`$sc$ with $mt_1$ with $\ldots$ with $mt_n$ { $\mathit{stats}$ }`
+definitions. A template
+`$sc$ with $mt_1$ with $\ldots$ with $mt_n$ { $\mathit{stats}$ }`
consists of a constructor invocation $sc$
which defines the template's _superclass_, trait references
`$mt_1 , \ldots , mt_n$` $(n \geq 0)$, which define the
@@ -61,7 +60,7 @@ superclass.
The _least proper supertype_ of a template is the class type or
[compound type](03-types.html#compound-types) consisting of all its parent
-class types.
+class types.
The statement sequence $\mathit{stats}$ contains member definitions that
define new members or overwrite members in the parent classes. If the
@@ -77,7 +76,7 @@ The sequence of template statements may be prefixed with a formal
parameter definition and an arrow, e.g. `$x$ =>`, or
`$x$:$T$ =>`. If a formal parameter is given, it can be
used as an alias for the reference `this` throughout the
-body of the template.
+body of the template.
If the formal parameter comes with a type $T$, this definition affects
the _self type_ $S$ of the underlying class or object as follows: Let $C$ be the type
of the class or trait or object defining the template.
@@ -87,11 +86,11 @@ If no type $T$ is given, $S$ is just $C$.
Inside the template, the type of `this` is assumed to be $S$.
The self type of a class or object must conform to the self types of
-all classes which are inherited by the template $t$.
+all classes which are inherited by the template $t$.
-A second form of self type annotation reads just
+A second form of self type annotation reads just
`this: $S$ =>`. It prescribes the type $S$ for `this`
-without introducing an alias name for it.
+without introducing an alias name for it.
###### Example
Consider the following class definitions:
@@ -108,21 +107,20 @@ In this case, the definition of `O` is expanded to:
object O extends Base with Mixin {}
```
-
<!-- TODO: Make all references to Java generic -->
**Inheriting from Java Types** A template may have a Java class as its superclass and Java interfaces as its
-mixins.
+mixins.
**Template Evaluation** Consider a template `$sc$ with $mt_1$ with $mt_n$ { $\mathit{stats}$ }`.
-If this is the template of a [trait](#traits) then its _mixin-evaluation_
+If this is the template of a [trait](#traits) then its _mixin-evaluation_
consists of an evaluation of the statement sequence $\mathit{stats}$.
If this is not a template of a trait, then its _evaluation_
consists of the following steps.
-- First, the superclass constructor $sc$ is
+- First, the superclass constructor $sc$ is
[evaluated](#constructor-invocations).
- Then, all base classes in the template's [linearization](#class-linearization)
up to the template's superclass denoted by $sc$ are
@@ -130,9 +128,8 @@ consists of the following steps.
occurrence in the linearization.
- Finally the statement sequence $\mathit{stats}\,$ is evaluated.
-
###### Delayed Initializaton
-The initialization code of an object or class (but not a trait) that follows
+The initialization code of an object or class (but not a trait) that follows
the superclass
constructor invocation and the mixin-evaluation of the template's base
classes is passed to a special hook, which is inaccessible from user
@@ -145,7 +142,6 @@ method, which is defined as follows:
def delayedInit(body: => Unit)
```
-
### Constructor Invocations
```ebnf
@@ -156,7 +152,7 @@ Constructor invocations define the type, members, and initial state of
objects created by an instance creation expression, or of parts of an
object's definition which are inherited by a class or object
definition. A constructor invocation is a function application
-`$x$.$c$[$\mathit{targs}$]($\mathit{args}_1$)$\ldots$($\mathit{args}_n$)`, where $x$ is a
+`$x$.$c$[$\mathit{targs}$]($\mathit{args}_1$)$\ldots$($\mathit{args}_n$)`, where $x$ is a
[stable identifier](03-types.html#paths), $c$ is a type name which either designates a
class or defines an alias type for one, $\mathit{targs}$ is a type argument
list, $\mathit{args}_1 , \ldots , \mathit{args}_n$ are argument lists, and there is a
@@ -171,12 +167,12 @@ it can be omitted, in which case a type argument list is synthesized
using [local type inference](06-expressions.html#local-type-inference). If no explicit
arguments are given, an empty list `()` is implicitly supplied.
-An evaluation of a constructor invocation
+An evaluation of a constructor invocation
`$x$.$c$[$\mathit{targs}$]($\mathit{args}_1$)$\ldots$($\mathit{args}_n$)`
consists of the following steps:
- First, the prefix $x$ is evaluated.
-- Then, the arguments $\mathit{args}_1 , \ldots , \mathit{args}_n$ are evaluated from
+- Then, the arguments $\mathit{args}_1 , \ldots , \mathit{args}_n$ are evaluated from
left to right.
- Finally, the class being constructed is initialized by evaluating the
template of the class referred to by $c$.
@@ -188,7 +184,6 @@ inheritance relation from a class $C$ are called the _base classes_ of $C$. Bec
on base classes forms in general a directed acyclic graph. A
linearization of this graph is defined as follows.
-
###### Definition: linearization
Let $C$ be a class with template
`$C_1$ with ... with $C_n$ { $\mathit{stats}$ }`.
@@ -206,7 +201,6 @@ $$
\end{array}
$$
-
###### Example
Consider the following class definitions.
@@ -245,7 +239,6 @@ For instance, the linearization of `RichIterator` is
which is not a suffix of the linearization of `Iter`.
-
### Class Members
A class $C$ defined by a template `$C_1$ with $\ldots$ with $C_n$ { $\mathit{stats}$ }`
@@ -294,8 +287,8 @@ $C_j \in \mathcal{L}(C)$ where $j < i$ which directly defines an abstract
member $M'$ matching $M$.
This definition also determines the [overriding](#overriding) relationships
-between matching members of a class $C$ and its parents.
-First, a concrete definition always overrides an abstract definition.
+between matching members of a class $C$ and its parents.
+First, a concrete definition always overrides an abstract definition.
Second, for definitions $M$ and $M$' which are both concrete or both abstract,
$M$ overrides $M'$ if $M$ appears in a class that precedes (in the
linearization of $C$) the class in which $M'$ is defined.
@@ -306,7 +299,6 @@ or inherited) with the same name and the same [erased type](03-types.html#type-e
Finally, a template is not allowed to contain two methods (directly
defined or inherited) with the same name which both define default arguments.
-
###### Example
Consider the trait definitions:
@@ -321,12 +313,11 @@ Then trait `D` has a directly defined abstract member `h`. It
inherits member `f` from trait `C` and member `g` from
trait `B`.
-
### Overriding
<!-- TODO: Explain that classes cannot override each other -->
-A member $M$ of class $C$ that [matches](#class-members)
+A member $M$ of class $C$ that [matches](#class-members)
a non-private member $M'$ of a
base class of $C$ is said to _override_ that member. In this case
the binding of the overriding member $M$ must [subsume](03-types.html#conformance)
@@ -345,9 +336,9 @@ $M'$:
labeled `protected`.
- If $M'$ is not an abstract member, then $M$ must be labeled `override`.
Furthermore, one of two possibilities must hold:
- - either $M$ is defined in a subclass of the class where is $M'$ is defined,
+ - either $M$ is defined in a subclass of the class where is $M'$ is defined,
- or both $M$ and $M'$ override a third member $M''$ which is defined
- in a base class of both the classes containing $M$ and $M'$
+ in a base class of both the classes containing $M$ and $M'$
- If $M'$ is [incomplete](#modifiers) in $C$ then $M$ must be
labeled `abstract override`.
- If $M$ and $M'$ are both concrete value definitions, then either none
@@ -399,7 +390,6 @@ definition of type `T` in class `C`:
class C extends A with B { type T <: C }
```
-
### Inheritance Closure
Let $C$ be a class type. The _inheritance closure_ of $C$ is the
@@ -435,9 +425,9 @@ constructor is called. In a template
```
The initial pattern definitions of $p_1 , \ldots , p_n$ are called
-_early definitions_. They define fields
+_early definitions_. They define fields
which form part of the template. Every early definition must define
-at least one variable.
+at least one variable.
An early definition is type-checked and evaluated in the scope which
is in effect just before the template being defined, augmented by any
@@ -453,7 +443,6 @@ always refer to the value that's defined there, and do not take into account
overriding definitions. In other words, a block of early definitions
is evaluated exactly as if it was a local bock containing a number of value
definitions.
-
Early definitions are evaluated in the order they are being defined
before the superclass constructor of the template is called.
@@ -483,11 +472,10 @@ body, it would be initialized after the constructor of
`Greeting`. In that case, `msg` would be initialized to
`"How are you, <null>"`.
-
## Modifiers
```ebnf
-Modifier ::= LocalModifier
+Modifier ::= LocalModifier
| AccessModifier
| `override'
LocalModifier ::= `abstract'
@@ -630,7 +618,6 @@ initialization might lead to looping behavior. If an exception is
thrown during initialization, the value is considered uninitialized,
and a later access will retry to evaluate its right hand side.
-
###### Example
The following code illustrates the use of qualified private:
@@ -653,7 +640,6 @@ package-private methods in Java. Finally, accesses to method
`h` can appear anywhere within package `outerpkg`,
including packages contained in it.
-
###### Example
A useful idiom to prevent clients of a class from
constructing new instances of that class is to declare the class
@@ -681,14 +667,13 @@ new m.C(0) {} // **** error: illegal inheritance from sealed class.
A similar access restriction can be achieved by marking the primary
constructor `private` ([example](#example-private-constructor)).
-
## Class Definitions
```ebnf
-TmplDef ::= `class' ClassDef
-ClassDef ::= id [TypeParamClause] {Annotation}
- [AccessModifier] ClassParamClauses ClassTemplateOpt
-ClassParamClauses ::= {ClassParamClause}
+TmplDef ::= `class' ClassDef
+ClassDef ::= id [TypeParamClause] {Annotation}
+ [AccessModifier] ClassParamClauses ClassTemplateOpt
+ClassParamClauses ::= {ClassParamClause}
[[nl] `(' implicit ClassParams `)']
ClassParamClause ::= [nl] `(' [ClassParams] ')'
ClassParams ::= ClassParam {`,' ClassParam}
@@ -697,7 +682,7 @@ ClassParam ::= {Annotation} {Modifier} [(`val' | `var')]
ClassTemplateOpt ::= `extends' ClassTemplate | [[`extends'] TemplateBody]
```
-The most general form of class definition is
+The most general form of class definition is
```scala
class $c$[$\mathit{tps}\,$] $as$ $m$($\mathit{ps}_1$)$\ldots$($\mathit{ps}_n$) extends $t$ $\quad(n \geq 0)$.
@@ -713,16 +698,16 @@ Here,
parameter section `[$\mathit{tps}\,$]` may be omitted. A class with a type
parameter section is called _polymorphic_, otherwise it is called
_monomorphic_.
- - $as$ is a possibly empty sequence of
+ - $as$ is a possibly empty sequence of
[annotations](11-user-defined-annotations.html#user-defined-annotations).
- If any annotations are given, they apply to the primary constructor of the
+ If any annotations are given, they apply to the primary constructor of the
class.
- $m$ is an [access modifier](#modifiers) such as
`private` or `protected`, possibly with a qualification.
If such an access modifier is given it applies to the primary constructor of the class.
- $(\mathit{ps}\_1)\ldots(\mathit{ps}\_n)$ are formal value parameter clauses for
the _primary constructor_ of the class. The scope of a formal value parameter includes
- all subsequent parameter sections and the template $t$. However, a formal
+ all subsequent parameter sections and the template $t$. However, a formal
value parameter may not form part of the types of any of the parent classes or members of the class template $t$.
It is illegal to define two formal value parameters with the same name.
@@ -742,19 +727,18 @@ Here,
- $t$ is a [template](#templates) of the form
- ```
+ ```
$sc$ with $mt_1$ with $\ldots$ with $mt_m$ { $\mathit{stats}$ } // $m \geq 0$
```
which defines the base classes, behavior and initial state of objects of
- the class. The extends clause
- `extends $sc$ with $mt_1$ with $\ldots$ with $mt_m$`
+ the class. The extends clause
+ `extends $sc$ with $mt_1$ with $\ldots$ with $mt_m$`
can be omitted, in which case
`extends scala.AnyRef` is assumed. The class body
`{ $\mathit{stats}$ }` may also be omitted, in which case the empty body
`{}` is assumed.
-
This class definition defines a type `$c$[$\mathit{tps}\,$]` and a constructor
which when applied to parameters conforming to types $\mathit{ps}$
initializes instances of type `$c$[$\mathit{tps}\,$]` by evaluating the template
@@ -782,11 +766,10 @@ class Sensitive private () {
}
```
-
### Constructor Definitions
```ebnf
-FunDef ::= `this' ParamClause ParamClauses
+FunDef ::= `this' ParamClause ParamClauses
(`=' ConstrExpr | [nl] ConstrBlock)
ConstrExpr ::= SelfInvocation
| ConstrBlock
@@ -814,16 +797,16 @@ to instantiate formal type parameters.
The signature and the self constructor invocation of a constructor
definition are type-checked and evaluated in the scope which is in
effect at the point of the enclosing class definition, augmented by
-any type parameters of the enclosing class and by any
+any type parameters of the enclosing class and by any
[early definitions](#early-definitions) of the enclosing template.
The rest of the
constructor expression is type-checked and evaluated as a function
body in the current class.
-
+
If there are auxiliary constructors of a class $C$, they form together
with $C$'s primary [constructor](#class-definitions)
an overloaded constructor
-definition. The usual rules for
+definition. The usual rules for
[overloading resolution](06-expressions.html#overloading-resolution)
apply for constructor invocations of $C$,
including for the self constructor invocations in the constructor
@@ -832,8 +815,7 @@ are never inherited. To prevent infinite cycles of constructor
invocations, there is the restriction that every self constructor
invocation must refer to a constructor definition which precedes it
(i.e. it must refer to either a preceding auxiliary constructor or the
-primary constructor of the class).
-
+primary constructor of the class).
###### Example
Consider the class definition
@@ -852,7 +834,6 @@ This defines a class `LinkedList` with three constructors. The
second constructor constructs an singleton list, while the
third one constructs a list with a given head and tail.
-
## Case Classes
```ebnf
@@ -860,7 +841,7 @@ TmplDef ::= `case' `class' ClassDef
```
If a class definition is prefixed with `case`, the class is said
-to be a _case class_.
+to be a _case class_.
The formal parameters in the first parameter section of a case class
are called _elements_; they are treated
@@ -905,7 +886,7 @@ def unapply[$\mathit{tps}\,$]($x$: $c$[$\mathit{tps}\,$]) = x ne null
```
The name of the `unapply` method is changed to `unapplySeq` if the first
-parameter section $\mathit{ps}_1$ of $c$ ends in a
+parameter section $\mathit{ps}_1$ of $c$ ends in a
[repeated parameter](04-basic-declarations-and-definitions.html#repeated-parameters).
If a companion object $c$ exists already, no new object is created,
but the `apply` and `unapply` methods are added to the existing
@@ -942,7 +923,6 @@ class different from `AnyRef`. In particular:
- Method `toString: String` returns a string representation which
contains the name of the class and its elements.
-
###### Example
Here is the definition of abstract syntax for lambda calculus:
@@ -985,7 +965,6 @@ This form of extensibility can be excluded by declaring the base class
directly extend `Expr` must be in the same source file as
`Expr`.
-
### Traits
```ebnf
@@ -1090,17 +1069,16 @@ methods are re-bound to refer to the corresponding implementations in
`ListTable`, which is the actual supertype of `SynchronizedTable`
in `MyTable`.
-
## Object Definitions
```ebnf
ObjectDef ::= id ClassTemplate
```
-An object definition defines a single object of a new class. Its
+An object definition defines a single object of a new class. Its
most general form is
`object $m$ extends $t$`. Here,
-$m$ is the name of the object to be defined, and
+$m$ is the name of the object to be defined, and
$t$ is a [template](#templates) of the form
```scala
@@ -1108,7 +1086,7 @@ $sc$ with $mt_1$ with $\ldots$ with $mt_n$ { $\mathit{stats}$ }
```
which defines the base classes, behavior and initial state of $m$.
-The extends clause `extends $sc$ with $mt_1$ with $\ldots$ with $mt_n$`
+The extends clause `extends $sc$ with $mt_1$ with $\ldots$ with $mt_n$`
can be omitted, in which case
`extends scala.AnyRef` is assumed. The class body
`{ $\mathit{stats}$ }` may also be omitted, in which case the empty body
@@ -1128,7 +1106,7 @@ not at the point of the object definition, but is instead evaluated
the first time $m$ is dereferenced during execution of the program
(which might be never at all). An attempt to dereference $m$ again in
the course of evaluation of the constructor leads to a infinite loop
-or run-time error.
+or run-time error.
Other threads trying to dereference $m$ while the
constructor is being evaluated block until evaluation is complete.
diff --git a/spec/06-expressions.md b/spec/06-expressions.md
index 7e0a5facf1..96a2558e61 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -48,7 +48,7 @@ Ascription ::= `:' InfixType
```
Expressions are composed of operators and operands. Expression forms are
-discussed subsequently in decreasing order of precedence.
+discussed subsequently in decreasing order of precedence.
## Expression Typing
@@ -70,7 +70,6 @@ Then the _packed type_ of $e$ is
$T$ forSome { type $t_1[\mathit{tps}\_1] >: L_1 <: U_1$; $\ldots$; type $t_n[\mathit{tps}\_n] >: L_n <: U_n$ }.
```
-
## Literals
```ebnf
@@ -80,7 +79,6 @@ SimpleExpr ::= Literal
Typing of literals is as described [here](01-lexical-syntax.html#literals); their
evaluation is immediate.
-
## The _Null_ Value
The `null` value is of type `scala.Null`, and is thus
@@ -90,15 +88,14 @@ implements methods in class `scala.AnyRef` as follows:
- `eq($x\,$)` and `==($x\,$)` return `true` iff the
argument $x$ is also the "null" object.
-- `ne($x\,$)` and `!=($x\,$)` return true iff the
+- `ne($x\,$)` and `!=($x\,$)` return true iff the
argument x is not also the "null" object.
- `isInstanceOf[$T\,$]` always returns `false`.
- `asInstanceOf[$T\,$]` returns the [default value](04-basic-declarations-and-definitions.html#value-declarations-and-definitions) of type $T$.
- `##` returns ``0``.
A reference to any other member of the "null" object causes a
-`NullPointerException` to be thrown.
-
+`NullPointerException` to be thrown.
## Designators
@@ -108,9 +105,9 @@ SimpleExpr ::= Path
```
A designator refers to a named term. It can be a _simple name_ or
-a _selection_.
+a _selection_.
-A simple name $x$ refers to a value as specified
+A simple name $x$ refers to a value as specified
[here](02-identifiers-names-and-scopes.html#identifiers-names-and-scopes).
If $x$ is bound by a definition or declaration in an enclosing class
or object $C$, it is taken to be equivalent to the selection
@@ -120,7 +117,7 @@ occurrence of $x$.
If $r$ is a [stable identifier](03-types.html#paths) of type $T$, the selection $r.x$ refers
statically to a term member $m$ of $r$ that is identified in $T$ by
-the name $x$.
+the name $x$.
<!-- There might be several such members, in which
case overloading resolution (\sref{overloading-resolution}) is applied
@@ -128,7 +125,7 @@ to pick a unique one.} -->
For other expressions $e$, $e.x$ is typed as
if it was `{ val $y$ = $e$; $y$.$x$ }`, for some fresh name
-$y$.
+$y$.
The expected type of a designator's prefix is always undefined. The
type of a designator is the type $T$ of the entity it refers to, with
@@ -147,16 +144,14 @@ designate a constant, or
conform to $\mathit{pt}$, or
1. The path $p$ designates a module.
-
The selection $e.x$ is evaluated by first evaluating the qualifier
expression $e$, which yields an object $r$, say. The selection's
result is then the member of $r$ that is either defined by $m$ or defined
-by a definition overriding $m$.
+by a definition overriding $m$.
If that member has a type which
conforms to `scala.NotNull`, the member's value must be initialized
to a value different from `null`, otherwise a `scala.UnitializedError`
is thrown.
-
## This and Super
@@ -190,7 +185,7 @@ method. <!-- explanation: so that we need not create several fields for overrid
If it is
a method, it must be concrete, or the template
containing the reference must have a member $m'$ which overrides $m$
-and which is labeled `abstract override`.
+and which is labeled `abstract override`.
A reference `$C$.super.$m$` refers statically to a method
or type $m$ in the least proper supertype of the innermost enclosing class or
@@ -238,7 +233,6 @@ Then we have:
Note that the `superB` function returns different results
depending on whether `B` is mixed in with class `Root` or `A`.
-
## Function Applications
```ebnf
@@ -276,13 +270,12 @@ is compatible with $T_i$.
- If the expected type is defined, the result type $U$ is
compatible to it.
-If $f$ is a polymorphic method it is applicable if
+If $f$ is a polymorphic method it is applicable if
[local type inference](#local-type-inference) can
determine type arguments so that the instantiated method is applicable. If
$f$ has some value type it is applicable if it has a method member named
`apply` which is applicable.
-
Evaluation of `$f$($e_1 , \ldots , e_n$)` usually entails evaluation of
$f$ and $e_1 , \ldots , e_n$ in that order. Each argument expression
is converted to the type of its corresponding formal parameter. After
@@ -295,7 +288,7 @@ The case of a formal parameter with a parameterless
method type `=>$T$` is treated specially. In this case, the
corresponding actual argument expression $e$ is not evaluated before the
application. Instead, every use of the formal parameter on the
-right-hand side of the rewrite rule entails a re-evaluation of $e$.
+right-hand side of the rewrite rule entails a re-evaluation of $e$.
In other words, the evaluation order for
`=>`-parameters is _call-by-name_ whereas the evaluation
order for normal parameters is _call-by-value_.
@@ -345,7 +338,6 @@ sum(List(1, 2, 3, 4))
would not typecheck.
-
### Named and Default Arguments
If an application might uses named arguments $p = e$ or default
@@ -360,10 +352,9 @@ arguments, the following conditions must hold.
- Every formal parameter $p_j:T_j$ which is not specified by either a positional
or a named argument has a default argument.
-
If the application uses named or default
arguments the following transformation is applied to convert it into
-an application without named or default arguments.
+an application without named or default arguments.
If the function $f$
has the form `$p.m$[$\mathit{targs}$]` it is transformed into the
@@ -395,7 +386,7 @@ for every argument in $e_1 , \ldots , e_m$, which is initialised to $e_i$ for
positional arguments and to $e'_i$ for named arguments of the form
`$x_i=e'_i$`. Then, for every parameter which is not specified
by the argument list, a value definition using a fresh name $z_i$ is created,
-which is initialized using the method computing the
+which is initialized using the method computing the
[default argument](04-basic-declarations-and-definitions.html#function-declarations-and-definitions) of
this parameter.
@@ -419,7 +410,6 @@ The final result of the transformation is a block of the form
}
```
-
## Method Values
```ebnf
@@ -430,7 +420,7 @@ The expression `$e$ _` is well-formed if $e$ is of method
type or if $e$ is a call-by-name parameter. If $e$ is a method with
parameters, `$e$ _` represents $e$ converted to a function
type by [eta expansion](#eta-expansion). If $e$ is a
-parameterless method or call-by-name parameter of type
+parameterless method or call-by-name parameter of type
`=>$T$`, `$e$ _` represents the function of type
`() => $T$`, which evaluates $e$ when it is applied to the empty
parameterlist `()`.
@@ -446,12 +436,9 @@ The method values in the left column are each equivalent to the [eta-expanded ex
|`(1 to 9).fold(z)_` | `{ val eta1 = z; val eta2 = 1 to 9; op => eta2.fold(eta1)(op) }` |
|`Some(1).fold(??? : Int)_` | `{ val eta1 = () => ???; val eta2 = Some(1); op => eta2.fold(eta1())(op) }` |
-
Note that a space is necessary between a method name and the trailing underscore
because otherwise the underscore would be considered part of the name.
-
-
## Type Applications
```ebnf
@@ -459,8 +446,8 @@ SimpleExpr ::= SimpleExpr TypeArgs
```
A type application `$e$[$T_1 , \ldots , T_n$]` instantiates
-a polymorphic value $e$ of type
-`[$a_1$ >: $L_1$ <: $U_1, \ldots , a_n$ >: $L_n$ <: $U_n$]$S$`
+a polymorphic value $e$ of type
+`[$a_1$ >: $L_1$ <: $U_1, \ldots , a_n$ >: $L_n$ <: $U_n$]$S$`
with argument types
`$T_1 , \ldots , T_n$`. Every argument type $T_i$ must obey
the corresponding bounds $L_i$ and $U_i$. That is, for each $i = 1
@@ -469,16 +456,15 @@ U_i$, where $\sigma$ is the substitution $[a_1 := T_1 , \ldots , a_n
:= T_n]$. The type of the application is $\sigma S$.
If the function part $e$ is of some value type, the type application
-is taken to be equivalent to
+is taken to be equivalent to
`$e$.apply[$T_1 , \ldots ,$ T$_n$]`, i.e. the application of an `apply` method defined by
$e$.
-Type applications can be omitted if
-[local type inference](#local-type-inference) can infer best type parameters
+Type applications can be omitted if
+[local type inference](#local-type-inference) can infer best type parameters
for a polymorphic functions from the types of the actual function arguments
and the expected result type.
-
## Tuples
```ebnf
@@ -486,20 +472,19 @@ SimpleExpr ::= `(' [Exprs] `)'
```
A tuple expression `($e_1 , \ldots , e_n$)` is an alias
-for the class instance creation
-`scala.Tuple$n$($e_1 , \ldots , e_n$)`, where $n \geq 2$.
+for the class instance creation
+`scala.Tuple$n$($e_1 , \ldots , e_n$)`, where $n \geq 2$.
The empty tuple
`()` is the unique value of type `scala.Unit`.
-
## Instance Creation Expressions
```ebnf
SimpleExpr ::= `new' (ClassTemplate | TemplateBody)
```
-A simple instance creation expression is of the form
-`new $c$`
+A simple instance creation expression is of the form
+`new $c$`
where $c$ is a [constructor invocation](05-classes-and-objects.html#constructor-invocations). Let $T$ be
the type of $c$. Then $T$ must
denote a (a type instance of) a non-abstract subclass of
@@ -521,7 +506,7 @@ The expression is evaluated by creating a fresh
object of type $T$ which is is initialized by evaluating $c$. The
type of the expression is $T$.
-A general instance creation expression is of the form
+A general instance creation expression is of the form
`new $t$` for some [class template](05-classes-and-objects.html#templates) $t$.
Such an expression is equivalent to the block
@@ -533,7 +518,7 @@ where $a$ is a fresh name of an _anonymous class_ which is
inaccessible to user programs.
There is also a shorthand form for creating values of structural
-types: If `{$D$}` is a class body, then
+types: If `{$D$}` is a class body, then
`new {$D$}` is equivalent to the general instance creation expression
`new AnyRef{$D$}`.
@@ -558,7 +543,6 @@ The latter is in turn a shorthand for the block
where `anon\$X` is some freshly created name.
-
## Blocks
```ebnf
@@ -574,31 +558,30 @@ two definitions or declarations that bind the same name in the same
namespace. The final expression can be omitted, in which
case the unit value `()` is assumed.
-
The expected type of the final expression $e$ is the expected
type of the block. The expected type of all preceding statements is
undefined.
The type of a block `$s_1$; $\ldots$; $s_n$; $e$` is
-`$T$ forSome {$\,Q\,$}`, where $T$ is the type of $e$ and $Q$
+`$T$ forSome {$\,Q\,$}`, where $T$ is the type of $e$ and $Q$
contains [existential clauses](03-types.html#existential-types)
-for every value or type name which is free in $T$
+for every value or type name which is free in $T$
and which is defined locally in one of the statements $s_1 , \ldots , s_n$.
We say the existential clause _binds_ the occurrence of the value or type name.
-Specifically,
+Specifically,
- A locally defined type definition `type$\;t = T$`
is bound by the existential clause `type$\;t >: T <: T$`.
- It is an error if $t$ carries type parameters.
+ It is an error if $t$ carries type parameters.
- A locally defined value definition `val$\;x: T = e$` is
bound by the existential clause `val$\;x: T$`.
- A locally defined class definition `class$\;c$ extends$\;t$`
is bound by the existential clause `type$\;c <: T$` where
$T$ is the least class type or refinement type which is a proper
- supertype of the type $c$. It is an error if $c$ carries type parameters.
+ supertype of the type $c$. It is an error if $c$ carries type parameters.
- A locally defined object definition `object$\;x\;$extends$\;t$`
is bound by the existential clause `val$\;x: T$` where
- $T$ is the least class type or refinement type which is a proper supertype of the type
+ $T$ is the least class type or refinement type which is a proper supertype of the type
`$x$.type`.
Evaluation of the block entails evaluation of its
@@ -623,18 +606,16 @@ simply has type `B`, because with the rules [here](03-types.html#simplification-
the existentially quantified type
`_1 forSome { type _1 <: B }` can be simplified to `B`.
-
## Prefix, Infix, and Postfix Operations
```ebnf
PostfixExpr ::= InfixExpr [id [nl]]
InfixExpr ::= PrefixExpr
| InfixExpr id [nl] InfixExpr
-PrefixExpr ::= [`-' | `+' | `!' | `~'] SimpleExpr
+PrefixExpr ::= [`-' | `+' | `!' | `~'] SimpleExpr
```
-Expressions can be constructed from operands and operators.
-
+Expressions can be constructed from operands and operators.
### Prefix Operations
@@ -656,7 +637,7 @@ application of the infix operator `sin` to the operands
### Postfix Operations
A postfix operator can be an arbitrary identifier. The postfix
-operation $e;\mathit{op}$ is interpreted as $e.\mathit{op}$.
+operation $e;\mathit{op}$ is interpreted as $e.\mathit{op}$.
### Infix Operations
@@ -687,7 +668,7 @@ There's one exception to this rule, which concerns
[_assignment operators_](#assignment-operators).
The precedence of an assigment operator is the same as the one
of simple assignment `(=)`. That is, it is lower than the
-precedence of any other operator.
+precedence of any other operator.
The _associativity_ of an operator is determined by the operator's
last character. Operators ending in a colon ``:`' are
@@ -700,12 +681,12 @@ parts of an expression as follows.
expression, then operators with higher precedence bind more closely
than operators with lower precedence.
- If there are consecutive infix
- operations $e_0; \mathit{op}\_1; e_1; \mathit{op}\_2 \ldots \mathit{op}\_n; e_n$
- with operators $\mathit{op}\_1 , \ldots , \mathit{op}\_n$ of the same precedence,
+ operations $e_0; \mathit{op}\_1; e_1; \mathit{op}\_2 \ldots \mathit{op}\_n; e_n$
+ with operators $\mathit{op}\_1 , \ldots , \mathit{op}\_n$ of the same precedence,
then all these operators must
have the same associativity. If all operators are left-associative,
the sequence is interpreted as
- $(\ldots(e_0;\mathit{op}\_1;e_1);\mathit{op}\_2\ldots);\mathit{op}\_n;e_n$.
+ $(\ldots(e_0;\mathit{op}\_1;e_1);\mathit{op}\_2\ldots);\mathit{op}\_n;e_n$.
Otherwise, if all operators are right-associative, the
sequence is interpreted as
$e_0;\mathit{op}\_1;(e_1;\mathit{op}\_2;(\ldots \mathit{op}\_n;e_n)\ldots)$.
@@ -721,13 +702,13 @@ A left-associative binary
operation $e_1;\mathit{op};e_2$ is interpreted as $e_1.\mathit{op}(e_2)$. If $\mathit{op}$ is
right-associative, the same operation is interpreted as
`{ val $x$=$e_1$; $e_2$.$\mathit{op}$($x\,$) }`, where $x$ is a fresh
-name.
+name.
### Assignment Operators
An assignment operator is an operator symbol (syntax category
`op` in [Identifiers](01-lexical-syntax.html#identifiers)) that ends in an equals character
-“`=`”, with the exception of operators for which one of
+“`=`”, with the exception of operators for which one of
the following conditions holds:
1. the operator also starts with an equals character, or
@@ -737,8 +718,8 @@ Assignment operators are treated specially in that they
can be expanded to assignments if no other interpretation is valid.
Let's consider an assignment operator such as `+=` in an infix
-operation `$l$ += $r$`, where $l$, $r$ are expressions.
-This operation can be re-interpreted as an operation which corresponds
+operation `$l$ += $r$`, where $l$, $r$ are expressions.
+This operation can be re-interpreted as an operation which corresponds
to the assignment
```scala
@@ -750,15 +731,14 @@ except that the operation's left-hand-side $l$ is evaluated only once.
The re-interpretation occurs if the following two conditions are fulfilled.
1. The left-hand-side $l$ does not have a member named
- `+=`, and also cannot be converted by an
+ `+=`, and also cannot be converted by an
[implicit conversion](#implicit-conversions)
to a value with a member named `+=`.
1. The assignment `$l$ = $l$ + $r$` is type-correct.
- In particular this implies that $l$ refers to a variable or object
- that can be assigned to, and that is convertible to a value with a member
+ In particular this implies that $l$ refers to a variable or object
+ that can be assigned to, and that is convertible to a value with a member
named `+`.
-
## Typed Expressions
```ebnf
@@ -778,18 +758,16 @@ Here are examples of well-typed and ill-typed expressions.
// 1: string // ***** illegal
```
-
## Annotated Expressions
```ebnf
-Expr1 ::= PostfixExpr `:' Annotation {Annotation}
+Expr1 ::= PostfixExpr `:' Annotation {Annotation}
```
An annotated expression `$e$: @$a_1$ $\ldots$ @$a_n$`
attaches [annotations](11-user-defined-annotations.html#user-defined-annotations) $a_1 , \ldots , a_n$ to the
expression $e$.
-
## Assignments
```ebnf
@@ -810,7 +788,7 @@ assignment `$f.x$ = $e$` to a parameterless function $x$
is interpreted as the invocation `$f.x$_=($e\,$)`.
An assignment `$f$($\mathit{args}\,$) = $e$` with a function application to the
-left of the ‘`=`’ operator is interpreted as
+left of the ‘`=`’ operator is interpreted as
`$f.$update($\mathit{args}$, $e\,$)`, i.e.
the invocation of an `update` function defined by $f$.
@@ -875,7 +853,6 @@ def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = {
}
```
-
## Conditional Expressions
```ebnf
@@ -900,7 +877,7 @@ evaluating $e_3$ is returned.
A short form of the conditional expression eliminates the
else-part. The conditional expression `if ($e_1$) $e_2$` is
-evaluated as if it was `if ($e_1$) $e_2$ else ()`.
+evaluated as if it was `if ($e_1$) $e_2$ else ()`.
## While Loop Expressions
@@ -917,7 +894,6 @@ def whileLoop(cond: => Boolean)(body: => Unit): Unit =
if (cond) { body ; whileLoop(cond)(body) } else {}
```
-
## Do Loop Expressions
```ebnf
@@ -928,11 +904,10 @@ The do loop expression `do $e_1$ while ($e_2$)` is typed and
evaluated as if it was the expression `($e_1$ ; while ($e_2$) $e_1$)`.
A semicolon preceding the `while` symbol of a do loop expression is ignored.
-
## For Comprehensions and For Loops
```ebnf
-Expr1 ::= `for' (`(' Enumerators `)' | `{' Enumerators `}')
+Expr1 ::= `for' (`(' Enumerators `)' | `{' Enumerators `}')
{nl} [`yield'] Expr
Enumerators ::= Generator {semi Generator}
Generator ::= Pattern1 `<-' Expr {[semi] Guard | semi Pattern1 `=' Expr}
@@ -947,7 +922,7 @@ and collects the results. An enumerator sequence always starts with a
generator; this can be followed by further generators, value
definitions, or guards. A _generator_ `$p$ <- $e$`
produces bindings from an expression $e$ which is matched in some way
-against pattern $p$. A _value definition_ `$p$ = $e$`
+against pattern $p$. A _value definition_ `$p$ = $e$`
binds the value name $p$ (or several names in a pattern $p$) to
the result of evaluating the expression $e$. A _guard_
`if $e$` contains a boolean expression which restricts
@@ -967,17 +942,17 @@ $p$ <- $e$.withFilter { case $p$ => true; case _ => false }
Then, the following rules are applied repeatedly until all
comprehensions have been eliminated.
- - A for comprehension
- `for ($p$ <- $e\,$) yield $e'$`
+ - A for comprehension
+ `for ($p$ <- $e\,$) yield $e'$`
is translated to
`$e$.map { case $p$ => $e'$ }`.
- A for loop
- `for ($p$ <- $e\,$) $e'$`
+ `for ($p$ <- $e\,$) $e'$`
is translated to
`$e$.foreach { case $p$ => $e'$ }`.
- A for comprehension
- ```
+ ```
for ($p$ <- $e$; $p'$ <- $e'; \ldots$) yield $e''$
```
@@ -985,13 +960,13 @@ comprehensions have been eliminated.
sequence of generators, definitions, or guards,
is translated to
- ```
+ ```
$e$.flatMap { case $p$ => for ($p'$ <- $e'; \ldots$) yield $e''$ }
```
- A for loop
- ```
+ ```
for ($p$ <- $e$; $p'$ <- $e'; \ldots$) $e''$
```
@@ -999,24 +974,23 @@ comprehensions have been eliminated.
sequence of generators, definitions, or guards,
is translated to
- ```
+ ```
$e$.foreach { case $p$ => for ($p'$ <- $e'; \ldots$) $e''$ }
```
- A generator `$p$ <- $e$` followed by a guard
- `if $g$` is translated to a single generator
+ `if $g$` is translated to a single generator
`$p$ <- $e$.withFilter(($x_1 , \ldots , x_n$) => $g\,$)` where
$x_1 , \ldots , x_n$ are the free variables of $p$.
- - A generator `$p$ <- $e$` followed by a value definition
+ - A generator `$p$ <- $e$` followed by a value definition
`$p'$ = $e'$` is translated to the following generator of pairs of values, where
$x$ and $x'$ are fresh names:
- ```
+ ```
($p$, $p'$) <- for ($x @ p$ <- $e$) yield { val $x' @ p'$ = $e'$; ($x$, $x'$) }
```
-
###### Example
The following code produces all pairs of numbers between $1$ and $n-1$
whose sums are prime.
@@ -1078,7 +1052,6 @@ The code above makes use of the fact that `map`, `flatMap`,
`withFilter`, and `foreach` are defined for instances of class
`scala.Array`.
-
## Return Expressions
```ebnf
@@ -1088,11 +1061,11 @@ Expr1 ::= `return' [Expr]
A return expression `return $e$` must occur inside the body of some
enclosing named method or function. The innermost enclosing named
method or function in a source program, $f$, must have an explicitly declared result type,
-and the type of $e$ must conform to it.
+and the type of $e$ must conform to it.
The return expression
evaluates the expression $e$ and returns its value as the result of
$f$. The evaluation of any statements or
-expressions following the return expression is omitted. The type of
+expressions following the return expression is omitted. The type of
a return expression is `scala.Nothing`.
The expression $e$ may be omitted. The return expression
@@ -1116,7 +1089,6 @@ before the return expression is executed. In that case, the thrown
`scala.runtime.NonLocalReturnException` will not be caught,
and will propagate up the call stack.
-
## Throw Expressions
```ebnf
@@ -1134,16 +1106,15 @@ exception, evaluation resumes with the handler; otherwise the thread
executing the `throw` is aborted. The type of a throw expression
is `scala.Nothing`.
-
## Try Expressions
```ebnf
-Expr1 ::= `try' `{' Block `}' [`catch' `{' CaseClauses `}']
+Expr1 ::= `try' `{' Block `}' [`catch' `{' CaseClauses `}']
[`finally' Expr]
```
A try expression is of the form `try { $b$ } catch $h$`
-where the handler $h$ is a
+where the handler $h$ is a
[pattern matching anonymous function](#pattern-matching-anonymous-functions)
```scala
@@ -1152,12 +1123,12 @@ where the handler $h$ is a
This expression is evaluated by evaluating the block
$b$. If evaluation of $b$ does not cause an exception to be
-thrown, the result of $b$ is returned. Otherwise the
-handler $h$ is applied to the thrown exception.
+thrown, the result of $b$ is returned. Otherwise the
+handler $h$ is applied to the thrown exception.
If the handler contains a case matching the thrown exception,
the first such case is invoked. If the handler contains
-no case matching the thrown exception, the exception is
-re-thrown.
+no case matching the thrown exception, the exception is
+re-thrown.
Let $\mathit{pt}$ be the expected type of the try expression. The block
$b$ is expected to conform to $\mathit{pt}$. The handler $h$
@@ -1173,7 +1144,7 @@ thrown, the expression $e$ is evaluated. If an exception is thrown
during evaluation of $e$, the evaluation of the try expression is
aborted with the thrown exception. If no exception is thrown during
evaluation of $e$, the result of $b$ is returned as the
-result of the try expression.
+result of the try expression.
If an exception is thrown during evaluation of $b$, the finally block
$e$ is also evaluated. If another exception $e$ is thrown
@@ -1185,11 +1156,10 @@ $b$ is expected to conform to the expected type of the try
expression. The finally expression $e$ is expected to conform to
type `Unit`.
-A try expression `try { $b$ } catch $e_1$ finally $e_2$`
+A try expression `try { $b$ } catch $e_1$ finally $e_2$`
is a shorthand
for `try { try { $b$ } catch $e_1$ } finally $e_2$`.
-
## Anonymous Functions
```ebnf
@@ -1199,7 +1169,7 @@ Bindings ::= `(' Binding {`,' Binding} `)'
Binding ::= (id | `_') [`:' Type]
```
-The anonymous function `($x_1$: $T_1 , \ldots , x_n$: $T_n$) => e`
+The anonymous function `($x_1$: $T_1 , \ldots , x_n$: $T_n$) => e`
maps parameters $x_i$ of types $T_i$ to a result given
by expression $e$. The scope of each formal parameter
$x_i$ is $e$. Formal parameters must have pairwise distinct names.
@@ -1226,14 +1196,14 @@ new scala.Function$n$[$T_1 , \ldots , T_n$, $T$] {
}
```
-In the case of a single untyped formal parameter,
-`($x\,$) => $e$`
+In the case of a single untyped formal parameter,
+`($x\,$) => $e$`
can be abbreviated to `$x$ => $e$`. If an
anonymous function `($x$: $T\,$) => $e$` with a single
typed parameter appears as the result expression of a block, it can be
abbreviated to `$x$: $T$ => e`.
-A formal parameter may also be a wildcard represented by an underscore `_`.
+A formal parameter may also be a wildcard represented by an underscore `_`.
In that case, a fresh name for the parameter is chosen arbitrarily.
A named parameter of an anonymous function may be optionally preceded
@@ -1262,7 +1232,6 @@ _ => 5 // The function that ignores its argument
// and always returns 5.
```
-
### Placeholder Syntax for Anonymous Functions
```ebnf
@@ -1281,10 +1250,10 @@ type ascription `_:$T$`.
An expression $e$ of syntactic category `Expr` _binds_ an underscore section
$u$, if the following two conditions hold: (1) $e$ properly contains $u$, and
-(2) there is no other expression of syntactic category `Expr`
+(2) there is no other expression of syntactic category `Expr`
which is properly contained in $e$ and which itself properly contains $u$.
-If an expression $e$ binds underscore sections $u_1 , \ldots , u_n$, in this order, it is equivalent to
+If an expression $e$ binds underscore sections $u_1 , \ldots , u_n$, in this order, it is equivalent to
the anonymous function `($u'_1$, ... $u'_n$) => $e'$`
where each $u_i'$ results from $u_i$ by replacing the underscore with a fresh identifier and
$e'$ results from $e$ by replacing each underscore section $u_i$ by $u_i'$.
@@ -1302,7 +1271,6 @@ syntax. Each of these is equivalent to the anonymous function on its right.
|`_.map(f)` | `x => x.map(f)` |
|`_.map(_ + 1)` | `x => x.map(y => y + 1)` |
-
## Constant Expressions
Constant expressions are expressions that the Scala compiler can evaluate to a constant.
@@ -1316,10 +1284,9 @@ include at least the expressions of the following forms:
- A literal array, of the form
`Array$(c_1 , \ldots , c_n)$`,
where all of the $c_i$'s are themselves constant expressions
-- An identifier defined by a
+- An identifier defined by a
[constant value definition](04-basic-declarations-and-definitions.html#value-declarations-and-definitions).
-
## Statements
```ebnf
@@ -1332,7 +1299,7 @@ TemplateStat ::= Import
| {Annotation} {Modifier} Def
| {Annotation} {Modifier} Dcl
| Expr
- |
+ |
```
Statements occur as parts of blocks and templates. A statement can be
@@ -1340,7 +1307,7 @@ an import, a definition or an expression, or it can be empty.
Statements used in the template of a class definition can also be
declarations. An expression that is used as a statement can have an
arbitrary value type. An expression statement $e$ is evaluated by
-evaluating $e$ and discarding the result of the evaluation.
+evaluating $e$ and discarding the result of the evaluation.
<!-- Generalize to implicit coercion? -->
@@ -1353,7 +1320,6 @@ permitted.
Evaluation of a statement sequence entails evaluation of the
statements in the order they are written.
-
## Implicit Conversions
Implicit conversions can be applied to expressions whose type does not
@@ -1361,7 +1327,7 @@ match their expected type, to qualifiers in selections, and to unapplied methods
available implicit conversions are given in the next two sub-sections.
We say, a type $T$ is _compatible_ to a type $U$ if $T$ weakly conforms
-to $U$ after applying [eta-expansion](#eta-expansion) and
+to $U$ after applying [eta-expansion](#eta-expansion) and
[view applications](07-implicit-parameters-and-views.html#views).
### Value Conversions
@@ -1371,11 +1337,10 @@ expression $e$ which has some value type $T$ and which is type-checked with
some expected type $\mathit{pt}$.
#### Overloading Resolution
-If an expression denotes several possible members of a class,
+If an expression denotes several possible members of a class,
[overloading resolution](#overloading-resolution)
is applied to pick a unique member.
-
###### Type Instantiation
An expression $e$ of polymorphic type
@@ -1386,7 +1351,7 @@ An expression $e$ of polymorphic type
which does not appear as the function part of
a type application is converted to a type instance of $T$
by determining with [local type inference](#local-type-inference)
-instance types `$T_1 , \ldots , T_n$`
+instance types `$T_1 , \ldots , T_n$`
for the type variables `$a_1 , \ldots , a_n$` and
implicitly embedding $e$ in the [type application](#type-applications)
`$e$[$T_1 , \ldots , T_n$]`.
@@ -1405,7 +1370,7 @@ type, it is converted to the same literal in that type.
###### Value Discarding
If $e$ has some value type and the expected type is `Unit`,
-$e$ is converted to the expected type by embedding it in the
+$e$ is converted to the expected type by embedding it in the
term `{ $e$; () }`.
###### View Application
@@ -1416,7 +1381,7 @@ $e$ to the expected type with a [view](07-implicit-parameters-and-views.html#vie
###### Dynamic Member Selection
If none of the previous conversions applies, and $e$ is a prefix
of a selection $e.x$, and $e$'s type conforms to class `scala.Dynamic`,
-then the selection is rewritten according to the rules for
+then the selection is rewritten according to the rules for
[dynamic member selection](#dynamic-member-selection).
### Method Conversions
@@ -1450,7 +1415,7 @@ member. The way this is done depends on whether or not $e$ is used as
a function. Let $\mathscr{A}$ be the set of members referenced by $e$.
Assume first that $e$ appears as a function in an application, as in
-`$e$($e_1 , \ldots , e_m$)`.
+`$e$($e_1 , \ldots , e_m$)`.
One first determines the set of functions that is potentially
applicable based on the _shape_ of the arguments.
@@ -1464,7 +1429,7 @@ a type that is defined as follows:
- For a named argument `$n$ = $e$`: $\mathit{shape}(e)$.
- For all other expressions: `Nothing`.
-Let $\mathscr{B}$ be the set of alternatives in $\mathscr{A}$ that are
+Let $\mathscr{B}$ be the set of alternatives in $\mathscr{A}$ that are
[_applicable_](#function-applications)
to expressions $(e_1 , \ldots , e_n)$ of types
$(\mathit{shape}(e_1) , \ldots , \mathit{shape}(e_n))$.
@@ -1473,7 +1438,7 @@ alternative in $\mathscr{B}$, that alternative is chosen.
Otherwise, let $S_1 , \ldots , S_m$ be the vector of types obtained by
typing each argument with an undefined expected type. For every
-member $m$ in $\mathscr{B}$ one determines whether it is
+member $m$ in $\mathscr{B}$ one determines whether it is
applicable to expressions ($e_1 , \ldots , e_m$) of types $S_1
, \ldots , S_m$.
It is an error if none of the members in $\mathscr{B}$ is applicable. If there is one
@@ -1501,16 +1466,16 @@ question: given
types $T_1 , \ldots , T_n$.
- A polymorphic method of type
`[$a_1$ >: $L_1$ <: $U_1 , \ldots , a_n$ >: $L_n$ <: $U_n$]$T$` is
- as specific as some other member of type $S$ if $T$ is as
+ as specific as some other member of type $S$ if $T$ is as
specific as $S$ under the assumption that for
$i = 1 , \ldots , n$ each $a_i$ is an abstract type name
bounded from below by $L_i$ and from above by $U_i$.
- A member of any other type is always as specific as a parameterized method
or a polymorphic method.
-- Given two members of types $T$ and $U$ which are
+- Given two members of types $T$ and $U$ which are
neither parameterized nor polymorphic method types, the member of type $T$ is as specific as
- the member of type $U$ if the existential dual of $T$ conforms to the existential dual of $U$.
- Here, the existential dual of a polymorphic type
+ the member of type $U$ if the existential dual of $T$ conforms to the existential dual of $U$.
+ Here, the existential dual of a polymorphic type
`[$a_1$ >: $L_1$ <: $U_1 , \ldots , a_n$ >: $L_n$ <: $U_n$]$T$` is
`$T$ forSome { type $a_1$ >: $L_1$ <: $U_1$ $, \ldots ,$ type $a_n$ >: $L_n$ <: $U_n$}`.
The existential dual of every other type is the type itself.
@@ -1541,15 +1506,15 @@ in `$e$[$\mathit{targs}\,$]`. Then all alternatives in
$\mathscr{A}$ which take the same number of type parameters as there are type
arguments in $\mathit{targs}$ are chosen. It is an error if no such alternative exists.
If there are several such alternatives, overloading resolution is
-applied again to the whole expression `$e$[$\mathit{targs}\,$]`.
+applied again to the whole expression `$e$[$\mathit{targs}\,$]`.
Assume finally that $e$ does not appear as a function in either
an application or a type application. If an expected type is given,
let $\mathscr{B}$ be the set of those alternatives in $\mathscr{A}$ which are
-[compatible](#implicit-conversions) to it. Otherwise, let $\mathscr{B}$ be the same
+[compatible](#implicit-conversions) to it. Otherwise, let $\mathscr{B}$ be the same
as $\mathscr{A}$.
We choose in this case the most specific alternative among all
-alternatives in $\mathscr{B}$. It is an error if there is no
+alternatives in $\mathscr{B}$. It is an error if there is no
alternative in $\mathscr{B}$ which is more specific than all other
alternatives in $\mathscr{B}$.
@@ -1575,18 +1540,17 @@ def f(x: B, y: A) = $\ldots$
Then the application `f(a, a)` is rejected for being ambiguous, since
no most specific applicable signature exists.
-
### Local Type Inference
Local type inference infers type arguments to be passed to expressions
of polymorphic type. Say $e$ is of type [$a_1$ >: $L_1$ <: $U_1
, \ldots , a_n$ >: $L_n$ <: $U_n$]$T$ and no explicit type parameters
-are given.
+are given.
Local type inference converts this expression to a type
application `$e$[$T_1 , \ldots , T_n$]`. The choice of the
type arguments $T_1 , \ldots , T_n$ depends on the context in which
-the expression appears and on the expected type $\mathit{pt}$.
+the expression appears and on the expected type $\mathit{pt}$.
There are three cases.
###### Case 1: Selections
@@ -1594,7 +1558,7 @@ If the expression appears as the prefix of a selection with a name
$x$, then type inference is _deferred_ to the whole expression
$e.x$. That is, if $e.x$ has type $S$, it is now treated as having
type [$a_1$ >: $L_1$ <: $U_1 , \ldots , a_n$ >: $L_n$ <: $U_n$]$S$,
-and local type inference is applied in turn to infer type arguments
+and local type inference is applied in turn to infer type arguments
for $a_1 , \ldots , a_n$, using the context in which $e.x$ appears.
###### Case 2: Values
@@ -1602,7 +1566,7 @@ If the expression $e$ appears as a value without being applied to
value arguments, the type arguments are inferred by solving a
constraint system which relates the expression's type $T$ with the
expected type $\mathit{pt}$. Without loss of generality we can assume that
-$T$ is a value type; if it is a method type we apply
+$T$ is a value type; if it is a method type we apply
[eta-expansion](#eta-expansion) to convert it to a function type. Solving
means finding a substitution $\sigma$ of types $T_i$ for the type
parameters $a_i$ such that
@@ -1613,7 +1577,7 @@ parameters $a_i$ such that
- The expression's type conforms to the expected type, i.e.
$\sigma T <: \sigma \mathit{pt}$.
-It is a compile time error if no such substitution exists.
+It is a compile time error if no such substitution exists.
If several substitutions exist, local-type inference will choose for
each type variable $a_i$ a minimal or maximal type $T_i$ of the
solution space. A _maximal_ type $T_i$ will be chosen if the type
@@ -1722,7 +1686,6 @@ a = Int
so `Int` is the type inferred for `a`.
-
###### Example
Consider now the definition
@@ -1759,7 +1722,6 @@ a = scala.Any
so `scala.Any` is the type inferred for `a`.
-
### Eta Expansion
_Eta-expansion_ converts an expression of method type to an
@@ -1774,10 +1736,10 @@ for every argument type $T_i$ of the method ($i = 1 , \ldots ,
n$). The result of eta-conversion is then:
```scala
-{ val $x_1$ = $e_1$;
- $\ldots$
- val $x_m$ = $e_m$;
- ($y_1: T_1 , \ldots , y_n: T_n$) => $e'$($y_1 , \ldots , y_n$)
+{ val $x_1$ = $e_1$;
+ $\ldots$
+ val $x_m$ = $e_m$;
+ ($y_1: T_1 , \ldots , y_n: T_n$) => $e'$($y_1 , \ldots , y_n$)
}
```
@@ -1811,4 +1773,3 @@ is rewritten to
```scala
$e$.applyDynamic("$x$", $\mathit{args}$)
```
-
diff --git a/spec/07-implicit-parameters-and-views.md b/spec/07-implicit-parameters-and-views.md
index e07adc9e82..3a215e74fc 100644
--- a/spec/07-implicit-parameters-and-views.md
+++ b/spec/07-implicit-parameters-and-views.md
@@ -15,7 +15,7 @@ ParamClauses ::= {ParamClause} [nl] ‘(’ ‘implicit’ Params ‘)’
Template members and parameters labeled with an `implicit`
modifier can be passed to [implicit parameters](#implicit-parameters)
-and can be used as implicit conversions called [views](#views).
+and can be used as implicit conversions called [views](#views).
The `implicit` modifier is illegal for all
type members, as well as for [top-level objects](09-top-level-definitions.html#packagings).
@@ -41,7 +41,6 @@ object Monoids {
}
```
-
## Implicit Parameters
An implicit parameter list
@@ -57,7 +56,7 @@ parameters, such arguments will be automatically provided.
The actual arguments that are eligible to be passed to an implicit
parameter of type $T$ fall into two categories. First, eligible are
all identifiers $x$ that can be accessed at the point of the method
-call without a prefix and that denote an
+call without a prefix and that denote an
[implicit definition](#the-implicit-modifier)
or an implicit parameter. An eligible
identifier may thus be a local name, or a member of an enclosing
@@ -117,7 +116,6 @@ eligible object which matches the implicit formal parameter type
`Monoid[Int]` is `intMonoid` so this object will
be passed as implicit parameter.
-
This discussion also shows that implicit parameters are inferred after
any type arguments are [inferred](06-expressions.html#local-type-inference).
@@ -128,7 +126,7 @@ type of the list is also convertible to this type.
```scala
implicit def list2ordered[A](x: List[A])
- (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] =
+ (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] =
...
```
@@ -145,8 +143,8 @@ define a `sort` method over ordered lists:
def sort[A](xs: List[A])(implicit a2ordered: A => Ordered[A]) = ...
```
-We can apply `sort` to a list of lists of integers
-`yss: List[List[Int]]`
+We can apply `sort` to a list of lists of integers
+`yss: List[List[Int]]`
as follows:
```scala
@@ -161,11 +159,11 @@ sort(yss)(xs: List[Int] => list2ordered[Int](xs)(int2ordered)) .
The possibility of passing implicit arguments to implicit arguments
raises the possibility of an infinite recursion. For instance, one
-might try to define the following method, which injects _every_ type into the
+might try to define the following method, which injects _every_ type into the
`Ordered` class:
```scala
-implicit def magic[A](x: A)(implicit a2ordered: A => Ordered[A]): Ordered[A] =
+implicit def magic[A](x: A)(implicit a2ordered: A => Ordered[A]): Ordered[A] =
a2ordered(x)
```
@@ -178,7 +176,7 @@ expansion:
sort(arg)(x => magic(x)(x => magic(x)(x => ... )))
```
-To prevent such infinite expansions, the compiler keeps track of
+To prevent such infinite expansions, the compiler keeps track of
a stack of “open implicit types” for which implicit arguments are currently being
searched. Whenever an implicit argument for type $T$ is searched, the
“core type” of $T$ is added to the stack. Here, the _core type_
@@ -190,7 +188,7 @@ the implicit argument either definitely fails or succeeds. Everytime a
core type is added to the stack, it is checked that this type does not
dominate any of the other types in the set.
-Here, a core type $T$ _dominates_ a type $U$ if $T$ is
+Here, a core type $T$ _dominates_ a type $U$ if $T$ is
[equivalent](03-types.html#type-equivalence)
to $U$, or if the top-level type constructors of $T$ and $U$ have a
common element and $T$ is more complex than $U$.
@@ -212,7 +210,6 @@ the type:
- For any other singleton type, $\operatorname{complexity}(p.type) ~=~ 1 + \operatorname{complexity}(T)$, provided $p$ has type $T$;
- For a compound type, `$\operatorname{complexity}(T_1$ with $\ldots$ with $T_n)$` $= \Sigma\operatorname{complexity}(T_i)$
-
###### Example
When typing `sort(xs)` for some list `xs` of type `List[List[List[Int]]]`,
the sequence of types for
@@ -228,7 +225,6 @@ All types share the common type constructor `scala.Function1`,
but the complexity of the each new type is lower than the complexity of the previous types.
Hence, the code typechecks.
-
###### Example
Let `ys` be a list of some type which cannot be converted
to `Ordered`. For instance:
@@ -249,7 +245,6 @@ Throwable => Ordered[Throwable],
Since the second type in the sequence is equal to the first, the compiler
will issue an error signalling a divergent implicit expansion.
-
## Views
Implicit parameters and methods can also define implicit conversions
@@ -266,7 +261,7 @@ Views are applied in three situations:
$\mathit{pt}$. The search proceeds as in the case of implicit parameters,
where the implicit scope is the one of `$T$ => $\mathit{pt}$`. If
such a view is found, the expression $e$ is converted to
- `$v$($e$)`.
+ `$v$($e$)`.
1. In a selection $e.m$ with $e$ of type $T$, if the selector $m$ does
not denote an accessible member of $T$. In this case, a view $v$ is searched
which is applicable to $e$ and whose result contains a member named
@@ -275,13 +270,12 @@ Views are applied in three situations:
selection $e.m$ is converted to `$v$($e$).$m$`.
1. In a selection $e.m(\mathit{args})$ with $e$ of type $T$, if the selector
$m$ denotes some member(s) of $T$, but none of these members is applicable to the arguments
- $\mathit{args}$. In this case a view $v$ is searched which is applicable to $e$
+ $\mathit{args}$. In this case a view $v$ is searched which is applicable to $e$
and whose result contains a method $m$ which is applicable to $\mathit{args}$.
The search proceeds as in the case of implicit parameters, where
the implicit scope is the one of $T$. If such a view is found, the
selection $e.m$ is converted to `$v$($e$).$m(\mathit{args})$`.
-
The implicit view, if it is found, can accept is argument $e$ as a
call-by-value or as a call-by-name parameter. However, call-by-value
implicits take precedence over call-by-name implicits.
@@ -319,17 +313,16 @@ The first application of `list2ordered` converts the list
occurrence is part of an implicit parameter passed to the `<=`
method.
-
## Context Bounds and View Bounds
```ebnf
- TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type]
+ TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type]
{‘<%’ Type} {‘:’ Type}
```
A type parameter $A$ of a method or non-trait class may have one or more view
bounds `$A$ <% $T$`. In this case the type parameter may be
-instantiated to any type $S$ which is convertible by application of a
+instantiated to any type $S$ which is convertible by application of a
view to the bound $T$.
A type parameter $A$ of a method or non-trait class may also have one
@@ -375,10 +368,9 @@ def <= [B >: A <% Ordered[B]](that: B): Boolean
## Manifests
-
Manifests are type descriptors that can be automatically generated by
the Scala compiler as arguments to implicit parameters. The Scala
-standard library contains a hierarchy of four manifest classes,
+standard library contains a hierarchy of four manifest classes,
with `OptManifest`
at the top. Their signatures follow the outline below.
@@ -399,7 +391,7 @@ argument is selected.
Otherwise, let $\mathit{Mobj}$ be the companion object `scala.reflect.Manifest`
if $M$ is trait `Manifest`, or be
the companion object `scala.reflect.ClassManifest` otherwise. Let $M'$ be the trait
-`Manifest` if $M$ is trait `Manifest`, or be the trait `OptManifest` otherwise.
+`Manifest` if $M$ is trait `Manifest`, or be the trait `OptManifest` otherwise.
Then the following rules apply.
1. If $T$ is a value class or one of the classes `Any`, `AnyVal`, `Object`,
@@ -416,26 +408,25 @@ Then the following rules apply.
where $m_0$ is the manifest determined for $M'[S]$ and $ms$ are the
manifests determined for $M'[U_1], \ldots, M'[U_n]$.
1. If $T$ is some other class type with type arguments $U_1 , \ldots , U_n$,
- a manifest is generated
+ a manifest is generated
with the invocation `$\mathit{Mobj}$.classType[T](classOf[T], $ms$)`
where $ms$ are the
manifests determined for $M'[U_1] , \ldots , M'[U_n]$.
1. If $T$ is a singleton type `$p$.type`, a manifest is generated with
- the invocation `$\mathit{Mobj}$.singleType[T]($p$)`
+ the invocation `$\mathit{Mobj}$.singleType[T]($p$)`
1. If $T$ is a refined type $T' \{ R \}$, a manifest is generated for $T'$.
(That is, refinements are never reflected in manifests).
1. If $T$ is an intersection type
`$T_1$ with $, \ldots ,$ with $T_n$`
where $n > 1$, the result depends on whether a full manifest is
- to be determined or not.
+ to be determined or not.
If $M$ is trait `Manifest`, then
a manifest is generated with the invocation
`Manifest.intersectionType[T]($ms$)` where $ms$ are the manifests
determined for $M[T_1] , \ldots , M[T_n]$.
- Otherwise, if $M$ is trait `ClassManifest`,
+ Otherwise, if $M$ is trait `ClassManifest`,
then a manifest is generated for the [intersection dominator](03-types.html#type-erasure)
of the types $T_1 , \ldots , T_n$.
1. If $T$ is some other type, then if $M$ is trait `OptManifest`,
a manifest is generated from the designator `scala.reflect.NoManifest`.
If $M$ is a type different from `OptManifest`, a static error results.
-
diff --git a/spec/08-pattern-matching.md b/spec/08-pattern-matching.md
index 6f71196b0d..b23be5bbb6 100644
--- a/spec/08-pattern-matching.md
+++ b/spec/08-pattern-matching.md
@@ -15,7 +15,7 @@ chapter: 8
| Pattern2
Pattern2 ::= varid [‘@’ Pattern3]
| Pattern3
- Pattern3 ::= SimplePattern
+ Pattern3 ::= SimplePattern
| SimplePattern {id [nl] SimplePattern}
SimplePattern ::= ‘_’
| varid
@@ -68,18 +68,17 @@ which is treated as if it was a fresh variable on each occurrence.
### Typed Patterns
-
```ebnf
Pattern1 ::= varid `:' TypePat
| `_' `:' TypePat
```
A typed pattern $x: T$ consists of a pattern variable $x$ and a
-type pattern $T$. The type of $x$ is the type pattern $T$, where
+type pattern $T$. The type of $x$ is the type pattern $T$, where
each type variable and wildcard is replaced by a fresh, unknown type.
-This pattern matches any value matched by the [type pattern](#type-patterns)
+This pattern matches any value matched by the [type pattern](#type-patterns)
$T$; it binds the variable name to
-that value.
+that value.
### Pattern Binders
@@ -87,10 +86,10 @@ that value.
Pattern2 ::= varid `@' Pattern3
```
-A pattern binder `$x$@$p$` consists of a pattern variable $x$ and a
+A pattern binder `$x$@$p$` consists of a pattern variable $x$ and a
pattern $p$. The type of the variable $x$ is the static type $T$ of the pattern $p$.
-This pattern matches any value $v$ matched by the pattern $p$,
-provided the run-time type of $v$ is also an instance of $T$,
+This pattern matches any value $v$ matched by the pattern $p$,
+provided the run-time type of $v$ is also an instance of $T$,
and it binds the variable name to that value.
### Literal Patterns
@@ -175,7 +174,7 @@ repeated parameter. This is further discussed [here](#pattern-sequences).
```
A tuple pattern `($p_1 , \ldots , p_n$)` is an alias
-for the constructor pattern `scala.Tuple$n$($p_1 , \ldots , p_n$)`,
+for the constructor pattern `scala.Tuple$n$($p_1 , \ldots , p_n$)`,
where $n \geq 2$. The empty tuple
`()` is the unique value of type `scala.Unit`.
@@ -196,14 +195,14 @@ $x(p_1 , \ldots , p_n)$ if it takes exactly one argument and one of
the following applies:
* $n=0$ and `unapply`'s result type is `Boolean`. In this case
- the extractor pattern matches all values $v$ for which
+ the extractor pattern matches all values $v$ for which
`$x$.unapply($v$)` yields `true`.
* $n=1$ and `unapply`'s result type is `Option[$T$]`, for some
type $T$. In this case, the (only) argument pattern $p_1$ is typed in
turn with expected type $T$. The extractor pattern matches then all
values $v$ for which `$x$.unapply($v$)` yields a value of form
`Some($v_1$)`, and $p_1$ matches $v_1$.
-* $n>1$ and `unapply`'s result type is
+* $n>1$ and `unapply`'s result type is
`Option[($T_1 , \ldots , T_n$)]`, for some
types $T_1 , \ldots , T_n$. In this case, the argument patterns $p_1
, \ldots , p_n$ are typed in turn with expected types $T_1 , \ldots ,
@@ -250,7 +249,7 @@ First, in a constructor pattern $c(q_1 , \ldots , q_m, p_1 , \ldots , p_n)$, whe
Second, in an extractor pattern $x(q_1 , \ldots , q_m, p_1 , \ldots , p_n)$ if the extractor object $x$ does not have an `unapply` method,
but it does define an `unapplySeq` method with a result type conforming to `Option[(T_1, ... , T_m, Seq[S])]` (if `m = 0`, the type `Option[Seq[S]]` is also accepted). The expected type for the patterns $p_i$ is $S$.
-The last pattern in a pattern sequence may be a _sequence wildcard_ `_*`.
+The last pattern in a pattern sequence may be a _sequence wildcard_ `_*`.
Each element pattern $p_i$ is type-checked with
$S$ as expected type, unless it is a sequence wildcard. If a final
sequence wildcard is present, the pattern matches all values $v$ that
@@ -268,7 +267,7 @@ p_n$.
An infix operation pattern $p;\mathit{op};q$ is a shorthand for the
constructor or extractor pattern $\mathit{op}(p, q)$. The precedence and
-associativity of operators in patterns is the same as in
+associativity of operators in patterns is the same as in
[expressions](06-expressions.html#prefix-infix-and-postfix-operations).
An infix operation pattern $p;\mathit{op};(q_1 , \ldots , q_n)$ is a
@@ -284,7 +283,7 @@ shorthand for the constructor or extractor pattern $\mathit{op}(p, q_1
A pattern alternative `$p_1$ | $\ldots$ | $p_n$`
consists of a number of alternative patterns $p_i$. All alternative
patterns are type checked with the expected type of the pattern. They
-may no bind variables other than wildcards. The alternative pattern
+may no bind variables other than wildcards. The alternative pattern
matches a value $v$ if at least one its alternatives matches $v$.
### XML Patterns
@@ -315,7 +314,7 @@ A pattern $p$ is _irrefutable_ for a type $T$, if one of the following applies:
1. $p$ is a typed pattern $x: T'$, and $T <: T'$,
1. $p$ is a constructor pattern $c(p_1 , \ldots , p_n)$, the type $T$
is an instance of class $c$, the [primary constructor](05-classes-and-objects.html#class-definitions)
- of type $T$ has argument types $T_1 , \ldots , T_n$, and each $p_i$ is
+ of type $T$ has argument types $T_1 , \ldots , T_n$, and each $p_i$ is
irrefutable for $T_i$.
## Type Patterns
@@ -324,18 +323,18 @@ A pattern $p$ is _irrefutable_ for a type $T$, if one of the following applies:
TypePat ::= Type
```
-Type patterns consist of types, type variables, and wildcards.
+Type patterns consist of types, type variables, and wildcards.
A type pattern $T$ is of one of the following forms:
* A reference to a class $C$, $p.C$, or `$T$#$C$`. This
- type pattern matches any non-null instance of the given class.
+ type pattern matches any non-null instance of the given class.
Note that the prefix of the class, if it is given, is relevant for determining
class instances. For instance, the pattern $p.C$ matches only
instances of classes $C$ which were created with the path $p$ as
prefix.
The bottom types `scala.Nothing` and `scala.Null` cannot
- be used as type patterns, because they would match nothing in any case.
+ be used as type patterns, because they would match nothing in any case.
* A singleton type `$p$.type`. This type pattern matches only the value
denoted by the path $p$ (that is, a pattern match involved a
@@ -346,7 +345,7 @@ A type pattern $T$ is of one of the following forms:
the type patterns $T_i$.
* A parameterized type pattern $T[a_1 , \ldots , a_n]$, where the $a_i$
- are type variable patterns or wildcards `_`.
+ are type variable patterns or wildcards `_`.
This type pattern matches all values which match $T$ for
some arbitrary instantiation of the type variables and wildcards. The
bounds or alias type of these type variable are determined as
@@ -356,8 +355,7 @@ A type pattern $T$ is of one of the following forms:
$T_1$ is a type pattern. This type pattern matches any non-null instance
of type `scala.Array$[U_1]$`, where $U_1$ is a type matched by $T_1$.
-
-Types which are not of one of the forms described above are also
+Types which are not of one of the forms described above are also
accepted as type patterns. However, such type patterns will be translated to their
[erasure](03-types.html#type-erasure). The Scala
compiler will issue an "unchecked" warning for these patterns to
@@ -373,7 +371,6 @@ bound type variables in a typed pattern or constructor
pattern. Inference takes into account the expected type of the
pattern.
-
### Type parameter inference for typed patterns.
Assume a typed pattern $p: T'$. Let $T$ result from $T'$ where all wildcards in
@@ -386,7 +383,7 @@ the type variables $a_i$. The initial constraints set $\mathcal{C}\_0$ reflects
just the bounds of these type variables. That is, assuming $T$ has
bound type variables $a_1 , \ldots , a_n$ which correspond to class
type parameters $a_1' , \ldots , a_n'$ with lower bounds $L_1, \ldots , L_n$
-and upper bounds $U_1 , \ldots , U_n$, $\mathcal{C}_0$ contains the constraints
+and upper bounds $U_1 , \ldots , U_n$, $\mathcal{C}_0$ contains the constraints
$$
\begin{cases}
@@ -395,7 +392,6 @@ a_i &<: \sigma U_i & \quad (i = 1, \ldots , n) \\\\
\end{cases}
$$
-
where $\sigma$ is the substitution $[a_1' := a_1 , \ldots , a_n' :=a_n]$.
The set $\mathcal{C}_0$ is then augmented by further subtype constraints. There are two
@@ -432,7 +428,7 @@ We take $a_i >: L_i <: U_i$ where each $L_i$ is minimal and each $U_i$ is maxima
###### Case 2
We take $a_i >: L_i <: U_i$ and $b\_i >: L_i' <: U_i' $ where each $L_i$
and $L_j'$ is minimal and each $U_i$ and $U_j'$ is maximal such that
-$a_i >: L_i <: U_i$ for $i = 1 , \ldots , n$ and
+$a_i >: L_i <: U_i$ for $i = 1 , \ldots , n$ and
$b_j >: L_j' <: U_j'$ for $j = 1 , \ldots , m$
implies $\mathcal{C}\_0 \wedge \mathcal{C}\_0' \wedge \mathcal{C}_2$.
@@ -497,7 +493,6 @@ list `x` contains elements other than strings. The Scala
compiler will flag this potential loss of type-safety with an
"unchecked" warning message.
-
###### Example
Consider the program fragment
@@ -521,7 +516,6 @@ the case clause as an abstract type with lower and upper bound
`y.n`, of type `Int`, is found to conform to the
function's declared result type, `Number`.
-
## Pattern Matching Expressions
```ebnf
@@ -539,12 +533,12 @@ e match { case $p_1$ => $b_1$ $\ldots$ case $p_n$ => $b_n$ }
consists of a selector expression $e$ and a number $n > 0$ of
cases. Each case consists of a (possibly guarded) pattern $p_i$ and a
block $b_i$. Each $p_i$ might be complemented by a guard
-`if $e$` where $e$ is a boolean expression.
+`if $e$` where $e$ is a boolean expression.
The scope of the pattern
variables in $p_i$ comprises the pattern's guard and the corresponding block $b_i$.
Let $T$ be the type of the selector expression $e$ and let $a_1
-, \ldots , a_m$ be the type parameters of all methods enclosing
+, \ldots , a_m$ be the type parameters of all methods enclosing
the pattern matching expression. For every $a_i$, let $L_i$ be its
lower bound and $U_i$ be its higher bound. Every pattern $p \in \{p_1, , \ldots , p_n\}$
can be typed in two ways. First, it is attempted
@@ -597,7 +591,7 @@ If the selector of a pattern match is an instance of a
[`sealed` class](05-classes-and-objects.html#modifiers),
the compilation of pattern matching can emit warnings which diagnose
that a given set of patterns is not exhaustive, i.e. that there is a
-possibility of a `MatchError` being raised at run-time.
+possibility of a `MatchError` being raised at run-time.
### Example
@@ -639,14 +633,13 @@ Under the assumption `Int <: T <: Int` we can also
verify that the type right hand side of the second case, `Int`
conforms to its expected type, `T`.
-
## Pattern Matching Anonymous Functions
```ebnf
BlockExpr ::= `{' CaseClauses `}'
```
-An anonymous function can be defined by a sequence of cases
+An anonymous function can be defined by a sequence of cases
```scala
{ case $p_1$ => $b_1$ $\ldots$ case $p_n$ => $b_n$ }
@@ -663,8 +656,8 @@ If the expected type is `scala.Function$k$[$S_1 , \ldots , S_k$, $R$]`,
the expression is taken to be equivalent to the anonymous function:
```scala
-($x_1: S_1 , \ldots , x_k: S_k$) => ($x_1 , \ldots , x_k$) match {
- case $p_1$ => $b_1$ $\ldots$ case $p_n$ => $b_n$
+($x_1: S_1 , \ldots , x_k: S_k$) => ($x_1 , \ldots , x_k$) match {
+ case $p_1$ => $b_1$ $\ldots$ case $p_n$ => $b_n$
}
```
@@ -721,4 +714,3 @@ anonymous function:
case (a, (b, c)) => a + b * c
}
```
-
diff --git a/spec/09-top-level-definitions.md b/spec/09-top-level-definitions.md
index b9c78b23a1..847fab548d 100644
--- a/spec/09-top-level-definitions.md
+++ b/spec/09-top-level-definitions.md
@@ -23,7 +23,7 @@ A compilation unit consists of a sequence of packagings, import
clauses, and class and object definitions, which may be preceded by a
package clause.
-A compilation unit
+A compilation unit
```scala
package $p_1$;
@@ -34,7 +34,7 @@ $\mathit{stats}$
starting with one or more package
clauses is equivalent to a compilation unit consisting of the
-packaging
+packaging
```scala
package $p_1$ { $\ldots$
@@ -94,7 +94,6 @@ into a special empty package. That package cannot be named and
therefore cannot be imported. However, members of the empty package
are visible to each other without qualification.
-
## Package Objects
```ebnf
@@ -113,7 +112,6 @@ there is a name conflict, the behavior of the program is currently
undefined. It is expected that this restriction will be lifted in a
future version of Scala.
-
## Package References
```ebnf
@@ -121,12 +119,12 @@ QualId ::= id {‘.’ id}
```
A reference to a package takes the form of a qualified identifier.
-Like all other references, package references are relative. That is,
+Like all other references, package references are relative. That is,
a package reference starting in a name $p$ will be looked up in the
closest enclosing scope that defines a member named $p$.
The special predefined name `_root_` refers to the
-outermost root package which contains all top-level packages.
+outermost root package which contains all top-level packages.
###### Example
Consider the following program:
@@ -149,7 +147,6 @@ omitted, the name `b` would instead resolve to the package
`a.b`, and, provided that package does not also
contain a class `B`, a compiler-time error would result.
-
## Programs
A _program_ is a top-level object that has a member method
@@ -161,7 +158,7 @@ passed to the `main` method as a parameter of type
The `main` method of a program can be directly defined in the
object, or it can be inherited. The scala library defines a special class
`scala.App` whose body acts as a `main` method.
-An objects $m$ inheriting from this class is thus a program,
+An objects $m$ inheriting from this class is thus a program,
which executes the initializaton code of the object $m$.
###### Example
@@ -198,4 +195,3 @@ object HelloWorld extends App {
println("Hello World")
}
```
-
diff --git a/spec/10-xml-expressions-and-patterns.md b/spec/10-xml-expressions-and-patterns.md
index 8d4b459844..069f499ce9 100644
--- a/spec/10-xml-expressions-and-patterns.md
+++ b/spec/10-xml-expressions-and-patterns.md
@@ -14,7 +14,7 @@ changes being mandated by the possibility of embedding Scala code fragments.
## XML expressions
-XML expressions are expressions generated by the following production, where the
+XML expressions are expressions generated by the following production, where the
opening bracket `<` of the first element must be in a position to start the lexical
[XML mode](01-lexical-syntax.html#xml-mode).
@@ -29,13 +29,13 @@ related to entity resolution.
The following productions describe Scala's extensible markup language,
designed as close as possible to the W3C extensible markup language
-standard. Only the productions for attribute values and character data are changed.
+standard. Only the productions for attribute values and character data are changed.
Scala does not support declarations, CDATA sections or processing instructions.
Entity references are not resolved at runtime.
```ebnf
Element ::= EmptyElemTag
- | STag Content ETag
+ | STag Content ETag
EmptyElemTag ::= ‘<’ Name {S Attribute} [S] ‘/>’
@@ -52,17 +52,17 @@ XmlContent ::= Element
```
If an XML expression is a single element, its value is a runtime
-representation of an XML node (an instance of a subclass of
+representation of an XML node (an instance of a subclass of
`scala.xml.Node`). If the XML expression consists of more
than one element, then its value is a runtime representation of a
-sequence of XML nodes (an instance of a subclass of
+sequence of XML nodes (an instance of a subclass of
`scala.Seq[scala.xml.Node]`).
-If an XML expression is an entity reference, CDATA section, processing
-instructions or a comments, it is represented by an instance of the
+If an XML expression is an entity reference, CDATA section, processing
+instructions or a comments, it is represented by an instance of the
corresponding Scala runtime class.
-By default, beginning and trailing whitespace in element content is removed,
+By default, beginning and trailing whitespace in element content is removed,
and consecutive occurrences of whitespace are replaced by a single space
character `\u0020`. This behavior can be changed to preserve all whitespace
with a compiler option.
@@ -76,13 +76,13 @@ AttValue ::= ‘"’ {CharQ | CharRef} ‘"’
ScalaExpr ::= Block
-CharData ::= { CharNoRef } $\textit{ without}$ {CharNoRef}`{'CharB {CharNoRef}
+CharData ::= { CharNoRef } $\textit{ without}$ {CharNoRef}`{'CharB {CharNoRef}
$\textit{ and without}$ {CharNoRef}`]]>'{CharNoRef}
```
<!-- {% raw %} stupid liquid borks on the double brace below; brace yourself, liquid! -->
XML expressions may contain Scala expressions as attribute values or
-within nodes. In the latter case, these are embedded using a single opening
+within nodes. In the latter case, these are embedded using a single opening
brace `{` and ended by a closing brace `}`. To express a single opening braces
within XML text as generated by CharData, it must be doubled.
Thus, `{{` represents the XML text `{` and does not introduce an embedded Scala expression.
@@ -99,7 +99,7 @@ CharB ::= Char1 $\textit{ without}$ ‘{’
Name ::= XNameStart {NameChar}
-XNameStart ::= ‘_’ | BaseChar | Ideographic
+XNameStart ::= ‘_’ | BaseChar | Ideographic
$\textit{ (as in W3C XML, but without }$ ‘:’$)$
```
@@ -110,7 +110,7 @@ the opening bracket `<` of the element patterns must be in a position
to start the lexical [XML mode](01-lexical-syntax.html#xml-mode).
```ebnf
-XmlPattern ::= ElementPattern
+XmlPattern ::= ElementPattern
```
Well-formedness constraints of the XML specification apply.
@@ -123,18 +123,18 @@ XML patterns may contain [Scala patterns](08-pattern-matching.html#pattern-match
Whitespace is treated the same way as in XML expressions.
-By default, beginning and trailing whitespace in element content is removed,
+By default, beginning and trailing whitespace in element content is removed,
and consecutive occurrences of whitespace are replaced by a single space
character `\u0020`. This behavior can be changed to preserve all whitespace
with a compiler option.
```ebnf
ElemPattern ::= EmptyElemTagP
- | STagP ContentP ETagP
+ | STagP ContentP ETagP
EmptyElemTagP ::= ‘<’ Name [S] ‘/>’
-STagP ::= ‘<’ Name [S] ‘>’
-ETagP ::= ‘</’ Name [S] ‘>’
+STagP ::= ‘<’ Name [S] ‘>’
+ETagP ::= ‘</’ Name [S] ‘>’
ContentP ::= [CharData] {(ElemPattern|ScalaPatterns) [CharData]}
ContentP1 ::= ElemPattern
| Reference
@@ -144,4 +144,3 @@ ContentP1 ::= ElemPattern
| ScalaPatterns
ScalaPatterns ::= ‘{’ Patterns ‘}’
```
-
diff --git a/spec/11-user-defined-annotations.md b/spec/11-user-defined-annotations.md
index fd7a7f9d3f..2c5830c103 100644
--- a/spec/11-user-defined-annotations.md
+++ b/spec/11-user-defined-annotations.md
@@ -14,7 +14,7 @@ chapter: 11
User-defined annotations associate meta-information with definitions.
A simple annotation has the form `@$c$` or `@$c(a_1 , \ldots , a_n)$`.
Here, $c$ is a constructor of a class $C$, which must conform
-to the class `scala.Annotation`.
+to the class `scala.Annotation`.
Annotations may apply to definitions or declarations, types, or
expressions. An annotation of a definition or declaration appears in
@@ -122,7 +122,6 @@ Java platform, the following annotations have a standard meaning.
When applied to value declarations or definitions that have non-volatile
types, the annotation has no effect.
-
* `@specialized` When applied to the definition of a type parameter, this annotation causes
the compiler
to generate specialized definitions for primitive types. An optional list of
@@ -142,7 +141,6 @@ Java platform, the following annotations have a standard meaning.
a definition, the compiler will instead use the specialized version.
See the [specialization sid](http://docs.scala-lang.org/sips/completed/scala-specialization.html) for more details of the implementation.
-
Other annotations may be interpreted by platform- or
application-dependent tools. Class `scala.Annotation` has two
sub-traits which are used to indicate how these annotations are
@@ -163,4 +161,3 @@ mapped to the host environment. In particular, on both the Java and
the .NET platforms, such classes must be toplevel; i.e. they may not
be contained in another class or object. Additionally, on both
Java and .NET, all constructor arguments must be constant expressions.
-
diff --git a/spec/12-the-scala-standard-library.md b/spec/12-the-scala-standard-library.md
index 7ccbe0c9bd..2b3ac1742c 100644
--- a/spec/12-the-scala-standard-library.md
+++ b/spec/12-the-scala-standard-library.md
@@ -41,15 +41,15 @@ The signatures of these root classes are described by the following
definitions.
```scala
-package scala
+package scala
/** The universal root class */
abstract class Any {
/** Defined equality; abstract here */
- def equals(that: Any): Boolean
+ def equals(that: Any): Boolean
/** Semantic equality between values */
- final def == (that: Any): Boolean =
+ final def == (that: Any): Boolean =
if (null eq this) null eq that else this equals that
/** Semantic inequality between values */
@@ -73,11 +73,11 @@ abstract class Any {
}
/** The root class of all value types */
-final class AnyVal extends Any
+final class AnyVal extends Any
/** The root class of all reference types */
class AnyRef extends Any {
- def equals(that: Any): Boolean = this eq that
+ def equals(that: Any): Boolean = this eq that
final def eq(that: AnyRef): Boolean = $\ldots$ // reference equality
final def ne(that: AnyRef): Boolean = !(this eq that)
@@ -85,7 +85,7 @@ class AnyRef extends Any {
def toString: String = $\ldots$ // toString computed from hashCode and class name
def synchronized[T](body: => T): T // execute `body` in while locking `this`.
-}
+}
```
The type test `$x$.isInstanceOf[$T$]` is equivalent to a typed
@@ -103,10 +103,9 @@ of the form $D$ or $D[\mathit{tps}]$ where $D$ is a type member of some outer cl
In this case $T'$ is `$C$#$D$` (or `$C$#$D[tps]$`, respectively), whereas $T$ itself would expand to `$C$.this.$D[tps]$`.
In other words, an `isInstanceOf` test does not check that types have the same enclosing instance.
-
The test `$x$.asInstanceOf[$T$]` is treated specially if $T$ is a
[numeric value type](#value-classes). In this case the cast will
-be translated to an application of a [conversion method](#numeric-value-types)
+be translated to an application of a [conversion method](#numeric-value-types)
`x.to$T$`. For non-numeric values $x$ the operation will raise a
`ClassCastException`.
@@ -131,19 +130,19 @@ Subrange types, as well as `Int` and `Long` are called _integer types_, whereas
Numeric value types are ranked in the following partial order:
```scala
-Byte - Short
+Byte - Short
\
Int - Long - Float - Double
- /
- Char
+ /
+ Char
```
-`Byte` and `Short` are the lowest-ranked types in this order,
+`Byte` and `Short` are the lowest-ranked types in this order,
whereas `Double` is the highest-ranked. Ranking does _not_
imply a [conformance relationship](03-types.html#conformance); for
instance `Int` is not a subtype of `Long`. However, object
[`Predef`](#the-predef-object) defines [views](07-implicit-parameters-and-views.html#views)
-from every numeric value type to all higher-ranked numeric value types.
+from every numeric value type to all higher-ranked numeric value types.
Therefore, lower-ranked types are implicitly converted to higher-ranked types
when required by the [context](06-expressions.html#implicit-conversions).
@@ -182,7 +181,7 @@ Any numeric value type $T$ supports the following methods.
numeric value (as when going from `Long` to `Int` or from
`Int` to `Byte`) or it might lose precision (as when going
from `Double` to `Float` or when converting between
- `Long` and `Float`).
+ `Long` and `Float`).
Integer numeric value types support in addition the following operations:
@@ -228,7 +227,7 @@ def equals(other: Any): Boolean = other match {
```
The `hashCode` method returns an integer hashcode that maps equal
-numeric values to equal results. It is guaranteed to be the identity for
+numeric values to equal results. It is guaranteed to be the identity for
for type `Int` and for all subrange types.
The `toString` method displays its receiver as an integer or
@@ -284,7 +283,6 @@ abstract sealed class Int extends AnyVal {
}
```
-
### Class `Boolean`
Class `Boolean` has only two values: `true` and
@@ -292,7 +290,7 @@ Class `Boolean` has only two values: `true` and
class definition.
```scala
-package scala
+package scala
abstract sealed class Boolean extends AnyVal {
def && (p: => Boolean): Boolean = // boolean and
if (this) p else false
@@ -316,7 +314,7 @@ and `toString` from class `Any`.
The `equals` method returns `true` if the argument is the
same boolean value as the receiver, `false` otherwise. The
-`hashCode` method returns a fixed, implementation-specific hash-code when invoked on `true`,
+`hashCode` method returns a fixed, implementation-specific hash-code when invoked on `true`,
and a different, fixed, implementation-specific hash-code when invoked on `false`. The `toString` method
returns the receiver converted to a string, i.e. either `"true"` or `"false"`.
@@ -328,7 +326,7 @@ from class `Any`.
The `equals` method returns `true` if the argument is the
unit value `()`, `false` otherwise. The
-`hashCode` method returns a fixed, implementation-specific hash-code,
+`hashCode` method returns a fixed, implementation-specific hash-code,
The `toString` method returns `"()"`.
## Standard Reference Classes
@@ -347,7 +345,7 @@ it). For Scala clients the class is taken to support in each case a
method
```scala
-def + (that: Any): String
+def + (that: Any): String
```
which concatenates its left operand with the textual representation of its
@@ -359,7 +357,7 @@ Scala defines tuple classes `Tuple$n$` for $n = 2 , \ldots , 22$.
These are defined as follows.
```scala
-package scala
+package scala
case class Tuple$n$[+T_1, ..., +T_n](_1: T_1, ..., _$n$: T_$n$) {
def toString = "(" ++ _1 ++ "," ++ $\ldots$ ++ "," ++ _$n$ ++ ")"
}
@@ -375,10 +373,10 @@ Scala defines function classes `Function$n$` for $n = 1 , \ldots , 22$.
These are defined as follows.
```scala
-package scala
+package scala
trait Function$n$[-T_1, ..., -T_$n$, +R] {
def apply(x_1: T_1, ..., x_$n$: T_$n$): R
- def toString = "<function>"
+ def toString = "<function>"
}
```
@@ -391,7 +389,7 @@ class PartialFunction[-A, +B] extends Function1[A, B] {
}
```
-The implicitly imported [`Predef`](#the-predef-object) object defines the name
+The implicitly imported [`Predef`](#the-predef-object) object defines the name
`Function` as an alias of `Function1`.
### Class `Array`
@@ -449,8 +447,8 @@ explained in the following.
#### Variance
Unlike arrays in Java, arrays in Scala are _not_
-co-variant; That is, $S <: T$ does not imply
-`Array[$S$] $<:$ Array[$T$]` in Scala.
+co-variant; That is, $S <: T$ does not imply
+`Array[$S$] $<:$ Array[$T$]` in Scala.
However, it is possible to cast an array
of $S$ to an array of $T$ if such a cast is permitted in the host
environment.
@@ -505,7 +503,7 @@ over arrays and additional utility methods:
```scala
package scala
-object Array {
+object Array {
/** copies array elements from `src` to `dest`. */
def copy(src: AnyRef, srcPos: Int,
dest: AnyRef, destPos: Int, length: Int): Unit = $\ldots$
@@ -557,36 +555,36 @@ object Array {
## Class Node
```scala
-package scala.xml
+package scala.xml
trait Node {
/** the label of this node */
- def label: String
+ def label: String
/** attribute axis */
- def attribute: Map[String, String]
+ def attribute: Map[String, String]
/** child axis (all children of this node) */
- def child: Seq[Node]
+ def child: Seq[Node]
/** descendant axis (all descendants of this node) */
- def descendant: Seq[Node] = child.toList.flatMap {
- x => x::x.descendant.asInstanceOf[List[Node]]
- }
+ def descendant: Seq[Node] = child.toList.flatMap {
+ x => x::x.descendant.asInstanceOf[List[Node]]
+ }
/** descendant axis (all descendants of this node) */
- def descendant_or_self: Seq[Node] = this::child.toList.flatMap {
- x => x::x.descendant.asInstanceOf[List[Node]]
- }
+ def descendant_or_self: Seq[Node] = this::child.toList.flatMap {
+ x => x::x.descendant.asInstanceOf[List[Node]]
+ }
override def equals(x: Any): Boolean = x match {
- case that:Node =>
- that.label == this.label &&
- that.attribute.sameElements(this.attribute) &&
+ case that:Node =>
+ that.label == this.label &&
+ that.attribute.sameElements(this.attribute) &&
that.child.sameElements(this.child)
case _ => false
- }
+ }
/** XPath style projection function. Returns all children of this node
* that are labeled with 'that'. The document order is preserved.
@@ -594,40 +592,39 @@ trait Node {
def \(that: Symbol): NodeSeq = {
new NodeSeq({
that.name match {
- case "_" => child.toList
+ case "_" => child.toList
case _ =>
- var res:List[Node] = Nil
+ var res:List[Node] = Nil
for (x <- child.elements if x.label == that.name) {
- res = x::res
+ res = x::res
}
res.reverse
}
- })
+ })
}
- /** XPath style projection function. Returns all nodes labeled with the
+ /** XPath style projection function. Returns all nodes labeled with the
* name 'that' from the 'descendant_or_self' axis. Document order is preserved.
*/
def \\(that: Symbol): NodeSeq = {
new NodeSeq(
that.name match {
- case "_" => this.descendant_or_self
+ case "_" => this.descendant_or_self
case _ => this.descendant_or_self.asInstanceOf[List[Node]].
- filter(x => x.label == that.name)
+ filter(x => x.label == that.name)
})
}
/** hashcode for this XML node */
- override def hashCode =
- Utility.hashCode(label, attribute.toList.hashCode, child)
+ override def hashCode =
+ Utility.hashCode(label, attribute.toList.hashCode, child)
/** string representation of this node */
- override def toString = Utility.toXML(this)
+ override def toString = Utility.toXML(this)
}
```
-
## The `Predef` Object
The `Predef` object defines standard functions and type aliases
@@ -642,7 +639,7 @@ object Predef {
// classOf ---------------------------------------------------------
/** Returns the runtime representation of a class type. */
- def classOf[T]: Class[T] = null
+ def classOf[T]: Class[T] = null
// this is a dummy, classOf is handled by compiler.
// Standard type aliases ---------------------------------------------
@@ -651,7 +648,7 @@ object Predef {
type Class[T] = java.lang.Class[T]
// Miscellaneous -----------------------------------------------------
-
+
type Function[-A, +B] = Function1[A, B]
type Map[A, +B] = collection.immutable.Map[A, B]
@@ -668,7 +665,7 @@ object Predef {
val ClassManifest = scala.reflect.ClassManifest
val Manifest = scala.reflect.Manifest
val NoManifest = scala.reflect.NoManifest
-
+
def manifest[T](implicit m: Manifest[T]) = m
def classManifest[T](implicit m: ClassManifest[T]) = m
def optManifest[T](implicit m: OptManifest[T]) = m
@@ -711,7 +708,6 @@ object Predef {
}
```
-
```scala
// tupling ---------------------------------------------------------
@@ -755,13 +751,12 @@ object Predef {
}
```
-
### Predefined Implicit Definitions
The `Predef` object also contains a number of implicit definitions, which are available by default (because `Predef` is implicitly imported).
-Implicit definitions come in two priorities. High-priority implicits are defined in the `Predef` class itself whereas low priority implicits are defined in a class inherited by `Predef`. The rules of
+Implicit definitions come in two priorities. High-priority implicits are defined in the `Predef` class itself whereas low priority implicits are defined in a class inherited by `Predef`. The rules of
static [overloading resolution](06-expressions.html#overloading-resolution)
-stipulate that, all other things being equal, implicit resolution
+stipulate that, all other things being equal, implicit resolution
prefers high-priority implicits over low-priority ones.
The available low-priority implicits include definitions falling into the following categories.
@@ -777,13 +772,12 @@ The available low-priority implicits include definitions falling into the follow
1. An implicit conversion from `String` to `WrappedString`.
-
The available high-priority implicits include definitions falling into the following categories.
- * An implicit wrapper that adds `ensuring` methods
+ * An implicit wrapper that adds `ensuring` methods
with the following overloaded variants to type `Any`.
- ```
+ ```
def ensuring(cond: Boolean): A = { assert(cond); x }
def ensuring(cond: Boolean, msg: Any): A = { assert(cond, msg); x }
def ensuring(cond: A => Boolean): A = { assert(cond(x)); x }
@@ -793,7 +787,7 @@ The available high-priority implicits include definitions falling into the follo
* An implicit wrapper that adds a `->` method with the following implementation
to type `Any`.
- ```
+ ```
def -> [B](y: B): (A, B) = (x, y)
```
@@ -807,12 +801,12 @@ The available high-priority implicits include definitions falling into the follo
* An implicit wrapper that adds `+` and `formatted` method with the following
implementations to type `Any`.
- ```
+ ```
def +(other: String) = String.valueOf(self) + other
def formatted(fmtstr: String): String = fmtstr format self
```
- * Numeric primitive conversions that implement the transitive closure of the
+ * Numeric primitive conversions that implement the transitive closure of the
following mappings:
```
@@ -824,7 +818,7 @@ The available high-priority implicits include definitions falling into the follo
Float -> Double
```
- * Boxing and unboxing conversions between primitive types and their boxed
+ * Boxing and unboxing conversions between primitive types and their boxed
versions:
```
@@ -841,9 +835,8 @@ The available high-priority implicits include definitions falling into the follo
* An implicit definition that generates instances of type `T <:< T`, for
any type `T`. Here, `<:<` is a class defined as follows.
- ```
+ ```
sealed abstract class <:<[-From, +To] extends (From => To)
```
Implicit parameters of `<:<` types are typically used to implement type constraints.
-
diff --git a/spec/13-syntax-summary.md b/spec/13-syntax-summary.md
index 3eecc26eb4..86efcf70a8 100644
--- a/spec/13-syntax-summary.md
+++ b/spec/13-syntax-summary.md
@@ -30,7 +30,7 @@ opchar ::= // printableChar not matched by (whiteSpace | upper | lower
printableChar ::= // all characters in [\u0020, \u007F] inclusive
charEscapeSeq ::= ‘\‘ (‘b‘ | ‘t‘ | ‘n‘ | ‘f‘ | ‘r‘ | ‘"‘ | ‘'‘ | ‘\‘)
-op ::= opchar {opchar}
+op ::= opchar {opchar}
varid ::= lower idrest
plainid ::= upper idrest
| varid
@@ -45,7 +45,7 @@ hexNumeral ::= ‘0’ ‘x’ hexDigit {hexDigit}
digit ::= ‘0’ | nonZeroDigit
nonZeroDigit ::= ‘1’ | … | ‘9’
-floatingPointLiteral
+floatingPointLiteral
::= digit {digit} ‘.’ digit {digit} [exponentPart] [floatType]
| ‘.’ digit {digit} [exponentPart] [floatType]
| digit {digit} exponentPart [floatType]
@@ -99,7 +99,7 @@ grammar.
FunctionArgTypes ::= InfixType
| ‘(’ [ ParamType {‘,’ ParamType } ] ‘)’
ExistentialClause ::= ‘forSome’ ‘{’ ExistentialDcl {semi ExistentialDcl} ‘}’
- ExistentialDcl ::= ‘type’ TypeDcl
+ ExistentialDcl ::= ‘type’ TypeDcl
| ‘val’ ValDcl
InfixType ::= CompoundType {id [nl] CompoundType}
CompoundType ::= AnnotType {‘with’ AnnotType} [Refinement]
@@ -119,7 +119,7 @@ grammar.
TypePat ::= Type
Ascription ::= ‘:’ InfixType
- | ‘:’ Annotation {Annotation}
+ | ‘:’ Annotation {Annotation}
| ‘:’ ‘_’ ‘*’
Expr ::= (Bindings | [‘implicit’] id | ‘_’) ‘=>’ Expr
@@ -139,7 +139,7 @@ grammar.
PostfixExpr ::= InfixExpr [id [nl]]
InfixExpr ::= PrefixExpr
| InfixExpr id [nl] InfixExpr
- PrefixExpr ::= [‘-’ | ‘+’ | ‘~’ | ‘!’] SimpleExpr
+ PrefixExpr ::= [‘-’ | ‘+’ | ‘~’ | ‘!’] SimpleExpr
SimpleExpr ::= ‘new’ (ClassTemplate | TemplateBody)
| BlockExpr
| SimpleExpr1 [‘_’]
@@ -147,7 +147,7 @@ grammar.
| Path
| ‘_’
| ‘(’ [Exprs] ‘)’
- | SimpleExpr ‘.’ id
+ | SimpleExpr ‘.’ id
| SimpleExpr TypeArgs
| SimpleExpr1 ArgumentExprs
| XmlExpr
@@ -170,7 +170,7 @@ grammar.
Generator ::= Pattern1 ‘<-’ Expr {[semi] Guard | semi Pattern1 ‘=’ Expr}
CaseClauses ::= CaseClause { CaseClause }
- CaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Block
+ CaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Block
Guard ::= ‘if’ PostfixExpr
Pattern ::= Pattern1 { ‘|’ Pattern1 }
@@ -195,16 +195,16 @@ grammar.
TypeParamClause ::= ‘[’ VariantTypeParam {‘,’ VariantTypeParam} ‘]’
FunTypeParamClause::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
VariantTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeParam
- TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type]
+ TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type]
{‘<%’ Type} {‘:’ Type}
ParamClauses ::= {ParamClause} [[nl] ‘(’ ‘implicit’ Params ‘)’]
ParamClause ::= [nl] ‘(’ [Params] ‘)’
Params ::= Param {‘,’ Param}
Param ::= {Annotation} id [‘:’ ParamType] [‘=’ Expr]
- ParamType ::= Type
- | ‘=>’ Type
+ ParamType ::= Type
+ | ‘=>’ Type
| Type ‘*’
- ClassParamClauses ::= {ClassParamClause}
+ ClassParamClauses ::= {ClassParamClause}
[[nl] ‘(’ ‘implicit’ ClassParams ‘)’]
ClassParamClause ::= [nl] ‘(’ [ClassParams] ‘)’
ClassParams ::= ClassParam {‘,’ ClassParam}
@@ -213,7 +213,7 @@ grammar.
Bindings ::= ‘(’ Binding {‘,’ Binding ‘)’
Binding ::= (id | ‘_’) [‘:’ Type]
- Modifier ::= LocalModifier
+ Modifier ::= LocalModifier
| AccessModifier
| ‘override’
LocalModifier ::= ‘abstract’
@@ -234,7 +234,7 @@ grammar.
| Expr
|
SelfType ::= id [‘:’ Type] ‘=>’
- | ‘this’ ‘:’ Type ‘=>’
+ | ‘this’ ‘:’ Type ‘=>’
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
ImportExpr ::= StableId ‘.’ (id | ‘_’ | ImportSelectors)
@@ -263,15 +263,15 @@ grammar.
| ids ‘:’ Type ‘=’ ‘_’
FunDef ::= FunSig [‘:’ Type] ‘=’ Expr
| FunSig [nl] ‘{’ Block ‘}’
- | ‘this’ ParamClause ParamClauses
+ | ‘this’ ParamClause ParamClauses
(‘=’ ConstrExpr | [nl] ConstrBlock)
TypeDef ::= id [TypeParamClause] ‘=’ Type
TmplDef ::= [‘case’] ‘class’ ClassDef
| [‘case’] ‘object’ ObjectDef
| ‘trait’ TraitDef
- ClassDef ::= id [TypeParamClause] {ConstrAnnotation} [AccessModifier]
- ClassParamClauses ClassTemplateOpt
+ ClassDef ::= id [TypeParamClause] {ConstrAnnotation} [AccessModifier]
+ ClassParamClauses ClassTemplateOpt
TraitDef ::= id [TypeParamClause] TraitTemplateOpt
ObjectDef ::= id ClassTemplateOpt
ClassTemplateOpt ::= ‘extends’ ClassTemplate | [[‘extends’] TemplateBody]
@@ -284,7 +284,7 @@ grammar.
EarlyDefs ::= ‘{’ [EarlyDef {semi EarlyDef}] ‘}’ ‘with’
EarlyDef ::= {Annotation [nl]} {Modifier} PatVarDef
- ConstrExpr ::= SelfInvocation
+ ConstrExpr ::= SelfInvocation
| ConstrBlock
ConstrBlock ::= ‘{’ SelfInvocation {semi BlockStat} ‘}’
SelfInvocation ::= ‘this’ ArgumentExprs {ArgumentExprs}
@@ -294,7 +294,7 @@ grammar.
| Import
| Packaging
| PackageObject
- |
+ |
Packaging ::= ‘package’ QualId [nl] ‘{’ TopStatSeq ‘}’
PackageObject ::= ‘package’ ‘object’ ObjectDef
diff --git a/spec/14-references.md b/spec/14-references.md
index 8c169b9ea4..caae5796b2 100644
--- a/spec/14-references.md
+++ b/spec/14-references.md
@@ -4,7 +4,6 @@ layout: default
chapter: 14
---
-
# References
TODO (see comments in markdown source)
@@ -49,7 +48,6 @@ for syntactic definitions?",
month = nov
}
-
%% Book
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -116,7 +114,6 @@ for syntactic definitions?",
OPTannote = {}
}
-
%% InProceedings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -131,7 +128,6 @@ for syntactic definitions?",
\verb@http://www.cis.upenn.edu/~bcpierce/FOOL/FOOL10.html@}
}
-
%% Misc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -208,6 +204,4 @@ for syntactic definitions?",
short = {http://www.cis.upenn.edu/~bcpierce/papers/variance.pdf}
}
-
-
---> \ No newline at end of file
+-->
diff --git a/spec/README.md b/spec/README.md
index 4bba86feba..97c3fdf832 100644
--- a/spec/README.md
+++ b/spec/README.md
@@ -12,19 +12,17 @@ We use redcarpet 3.1 and jekyll 2 (currently in alpha) to generate the html. Ess
## Building
-Travis CI builds the spec automatically on every commit to master and publishes to http://www.scala-lang.org/files/archive/spec/2.11/.
+Travis CI builds the spec automatically on every commit to master and publishes to http://www.scala-lang.org/files/archive/spec/2.11/.
To preview locally, run `bundle exec jekyll serve -d build/spec/ -s spec/ -w --baseurl=""` (in the root of your checkout of scala/scala),
and open http://0.0.0.0:4000/. Jekyll will rebuild as you edit the markdown, but make sure to restart it when you change `_config.yml`.
-
## General Advice for editors
- All files must be saved as UTF-8: ensure your editors are configured appropriately.
- Use of the appropriate unicode characters instead of the latex modifiers for accents, etc. is necessary. For example, é instead of `\'e`.
- MathJAX errors will appear within the rendered DOM as span elements with class `mtext` and style attribute `color: red` applied. It is possible to search for this combination in the development tools of the browser of your choice. In chrome, CTRL+F / CMD+F within the inspect element panel allows you to do this.
-
### Macro replacements:
- While MathJAX just support LaTeX style command definition, it is recommended to not use this as it will likely cause issues with preparing the document for PDF or ebook distribution.
@@ -36,7 +34,6 @@ and open http://0.0.0.0:4000/. Jekyll will rebuild as you edit the markdown, but
- The macro \commadots can be replaced with ` , … , `.
- There is no adequate replacement for `\textsc{...}` (small caps) in pandoc markdown. While unicode contains a number of small capital letters, it is notably missing Q and X as these glyphs are intended for phonetic spelling, therefore these cannot be reliably used. For now, the best option is to use underscore emphasis and capitalise the text manually, `_LIKE THIS_`.
-
### Unicode Character replacements
- The unicode left and right single quotation marks (‘ and ’) have been used in place of ` and ', where the quotation marks are intended to be paired. These can be typed on a mac using Option+] for a left quote and Option+Shift+] for the right quote.
diff --git a/spec/index.md b/spec/index.md
index b47cb033cb..3815265ad5 100644
--- a/spec/index.md
+++ b/spec/index.md
@@ -25,7 +25,6 @@ layout: toc
{% endfor %}
</ol>
-
## Preface
Scala is a Java-like programming language which unifies
@@ -68,4 +67,3 @@ the language through lively and inspiring discussions and comments on
previous versions of this document. The contributors to the Scala
mailing list have also given very useful feedback that helped us
improve the language and its tools.
-