summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2014-09-16 18:48:09 +0200
committerSimon Ochsenreither <simon@ochsenreither.de>2015-04-25 03:37:40 +0200
commit62db8d98559766c06d490d9d4c18ff27587fde0b (patch)
treea2c6b72094a214b9ef99c8097759da0aba5ace51
parentd030172d7ef807d85391d32c5456b1b97b15a402 (diff)
downloadscala-62db8d98559766c06d490d9d4c18ff27587fde0b.tar.gz
scala-62db8d98559766c06d490d9d4c18ff27587fde0b.tar.bz2
scala-62db8d98559766c06d490d9d4c18ff27587fde0b.zip
Spec improvements
-rw-r--r--spec/01-lexical-syntax.md348
-rw-r--r--spec/02-identifiers-names-and-scopes.md4
-rw-r--r--spec/03-types.md23
-rw-r--r--spec/04-basic-declarations-and-definitions.md4
-rw-r--r--spec/05-classes-and-objects.md10
-rw-r--r--spec/06-expressions.md16
-rw-r--r--spec/07-implicits.md (renamed from spec/07-implicit-parameters-and-views.md)12
-rw-r--r--spec/08-pattern-matching.md6
-rw-r--r--spec/10-xml-expressions-and-patterns.md2
-rw-r--r--spec/11-annotations.md (renamed from spec/11-user-defined-annotations.md)31
-rw-r--r--spec/12-the-scala-standard-library.md6
-rw-r--r--spec/13-syntax-summary.md6
-rw-r--r--spec/15-changelog.md823
-rw-r--r--spec/README.md2
-rw-r--r--spec/_includes/numbering.css2
-rw-r--r--spec/_layouts/default.yml72
-rw-r--r--spec/_layouts/toc.yml26
-rw-r--r--spec/index.md21
-rw-r--r--spec/public/fonts/Heuristica-Bold.woffbin0 -> 106188 bytes
-rw-r--r--spec/public/fonts/Heuristica-BoldItalic.woffbin0 -> 104316 bytes
-rw-r--r--spec/public/fonts/Heuristica-Regular.woffbin0 -> 141416 bytes
-rw-r--r--spec/public/fonts/Heuristica-RegularItalic.woffbin0 -> 104700 bytes
-rw-r--r--spec/public/fonts/LuxiMono-Bold.woffbin0 -> 26560 bytes
-rw-r--r--spec/public/fonts/LuxiMono-BoldOblique.woffbin0 -> 29480 bytes
-rw-r--r--spec/public/fonts/LuxiMono-Regular.woffbin0 -> 26432 bytes
-rw-r--r--spec/public/fonts/LuxiMono-RegularOblique.woffbin0 -> 29300 bytes
-rw-r--r--spec/public/fonts/LuxiSans-Bold.woffbin0 -> 13592 bytes
-rw-r--r--spec/public/fonts/LuxiSans-Regular.woffbin0 -> 13568 bytes
-rw-r--r--spec/public/images/github-logo@2x.pngbin0 -> 1753 bytes
-rw-r--r--spec/public/images/scala-logo-red-spiral-dark.pngbin13021 -> 0 bytes
-rw-r--r--spec/public/images/scala-spiral-white.pngbin0 -> 1442 bytes
-rw-r--r--spec/public/scripts/LICENSE-highlight (renamed from spec/public/highlight/LICENSE)4
-rw-r--r--spec/public/scripts/LICENSE-toc18
-rw-r--r--spec/public/scripts/highlight.pack.js (renamed from spec/public/highlight/highlight.pack.js)0
-rw-r--r--spec/public/scripts/main.js57
-rw-r--r--spec/public/scripts/navigation.js70
-rw-r--r--spec/public/scripts/toc.js128
-rw-r--r--spec/public/stylesheets/fonts.css73
-rw-r--r--spec/public/stylesheets/screen-small.css57
-rw-r--r--spec/public/stylesheets/screen-toc.css37
-rw-r--r--spec/public/stylesheets/screen.css225
41 files changed, 1618 insertions, 465 deletions
diff --git a/spec/01-lexical-syntax.md b/spec/01-lexical-syntax.md
index 3972961f58..e26cb796c8 100644
--- a/spec/01-lexical-syntax.md
+++ b/spec/01-lexical-syntax.md
@@ -101,19 +101,18 @@ _ : = => <- <: <% >: # @
The Unicode operators `\u21D2` ‘$\Rightarrow$’ and `\u2190` ‘$\leftarrow$’, which have the ASCII
equivalents `=>` and `<-`, are also reserved.
-### Example
-Here are examples of identifiers:
-```scala
- x Object maxIndex p2p empty_?
- + `yield` αρετη _y dot_product_*
- __system _MAX_LEN_
-```
+> Here are examples of identifiers:
+> ```scala
+> x Object maxIndex p2p empty_?
+> + `yield` αρετη _y dot_product_*
+> __system _MAX_LEN_
+> ```
+
+<!-- -->
-### Example
-When one needs to access Java identifiers that are reserved words in Scala, use backquote-enclosed strings.
-For instance, the statement `Thread.yield()` is illegal, since
-`yield` is a reserved word in Scala. However, here's a
-work-around: `` Thread.`yield`() ``
+> When one needs to access Java identifiers that are reserved words in Scala, use backquote-enclosed strings.
+> 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
@@ -205,99 +204,96 @@ A single new line token is accepted
- after an [infix operator](06-expressions.html#prefix,-infix,-and-postfix-operations),
if the first token on the next line can start an expression,
- in front of a [parameter clause](04-basic-declarations-and-definitions.html#function-declarations-and-definitions), and
-- after an [annotation](11-user-defined-annotations.html#user-defined-annotations).
-
-### Example
-
-The newline tokens between the two lines are not
-treated as statement separators.
-
-```scala
-if (x > 0)
- x = x - 1
-
-while (x > 0)
- x = x / 2
-
-for (x <- 1 to 10)
- println(x)
-
-type
- IntList = List[Int]
-```
-
-### Example
-
-```scala
-new Iterator[Int]
-{
- private var x = 0
- def hasNext = true
- def next = { x += 1; x }
-}
-```
-
-With an additional newline character, the same code is interpreted as
-an object creation followed by a local block:
-
-```scala
-new Iterator[Int]
-
-{
- private var x = 0
- def hasNext = true
- def next = { x += 1; x }
-}
-```
-
-### Example
-
-```scala
- x < 0 ||
- x > 10
-```
-
-With an additional newline character, the same code is interpreted as
-two expressions:
-
-```scala
- x < 0 ||
-
- x > 10
-```
-
-### Example
-
-```scala
-def func(x: Int)
- (y: Int) = x + y
-```
-
-With an additional newline character, the same code is interpreted as
-an abstract function definition and a syntactically illegal statement:
-
-```scala
-def func(x: Int)
-
- (y: Int) = x + y
-```
-
-### Example
-
-```scala
-@serializable
-protected class Data { ... }
-```
-
-With an additional newline character, the same code is interpreted as
-an attribute and a separate statement (which is syntactically
-illegal).
-
-```scala
-@serializable
-
-protected class Data { ... }
-```
+- after an [annotation](11-annotations.html#user-defined-annotations).
+
+> The newline tokens between the two lines are not
+> treated as statement separators.
+>
+> ```scala
+> if (x > 0)
+> x = x - 1
+>
+> while (x > 0)
+> x = x / 2
+>
+> for (x <- 1 to 10)
+> println(x)
+>
+> type
+> IntList = List[Int]
+> ```
+
+<!-- -->
+
+> ```scala
+> new Iterator[Int]
+> {
+> private var x = 0
+> def hasNext = true
+> def next = { x += 1; x }
+> }
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an object creation followed by a local block:
+>
+> ```scala
+> new Iterator[Int]
+>
+> {
+> private var x = 0
+> def hasNext = true
+> def next = { x += 1; x }
+> }
+> ```
+
+<!-- -->
+
+> ```scala
+> x < 0 ||
+> x > 10
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> two expressions:
+>
+> ```scala
+> x < 0 ||
+>
+> x > 10
+> ```
+
+<!-- -->
+
+> ```scala
+> def func(x: Int)
+> (y: Int) = x + y
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an abstract function definition and a syntactically illegal statement:
+>
+> ```scala
+> def func(x: Int)
+>
+> (y: Int) = x + y
+> ```
+
+<!-- -->
+
+> ```scala
+> @serializable
+> protected class Data { ... }
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an attribute and a separate statement (which is syntactically illegal).
+>
+> ```scala
+> @serializable
+>
+> protected class Data { ... }
+> ```
## Literals
@@ -351,11 +347,9 @@ 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
-```
+> ```scala
+> 0 21 0xFFFFFFFF -42L
+> ```
### Floating Point Literals
@@ -379,20 +373,18 @@ If a floating point literal in a program is followed by a token
starting with a letter, there must be at least one intervening
whitespace character between the two tokens.
-### Example
+> ```scala
+> 0.0 1e30f 3.14159f 1.0e-100 .1
+> ```
-```scala
-0.0 1e30f 3.14159f 1.0e-100 .1
-```
+<!-- -->
-### Example
+> The phrase `1.toString` parses as three different tokens:
+> the integer literal `1`, a `.`, and the identifier `toString`.
-The phrase `1.toString` parses as three different tokens:
-the integer literal `1`, a `.`, and the identifier `toString`.
+<!-- -->
-### Example
-
-`1.` is not a valid floating point literal because the mandatory digit after the `.` is missing.
+> `1.` is not a valid floating point literal because the mandatory digit after the `.` is missing.
### Boolean Literals
@@ -413,11 +405,9 @@ A character literal is a single character enclosed in quotes.
The character is either a printable unicode character or is described
by an [escape sequence](#escape-sequences).
-### Example
-
-```scala
-'a' '\u0041' '\n' '\t'
-```
+> ```scala
+> 'a' '\u0041' '\n' '\t'
+> ```
Note that `'\u000A'` is _not_ a valid character literal because
Unicode conversion is done before literal parsing and the Unicode
@@ -439,12 +429,10 @@ contains a double quote character, it must be escaped,
i.e. `"\""`. The value of a string literal is an instance of
class `String`.
-### Example
-
-```scala
-"Hello,\nWorld!"
-"This string contains a \" character."
-```
+> ```scala
+> "Hello,\nWorld!"
+> "This string contains a \" character."
+> ```
#### Multi-Line String Literals
@@ -461,45 +449,43 @@ must not necessarily be printable; newlines or other
control characters are also permitted. Unicode escapes work as everywhere else, but none
of the escape sequences [here](#escape-sequences) are interpreted.
-### Example
-
-```scala
- """the present string
- spans three
- lines."""
-```
-
-This would produce the string:
-
-```scala
-the present string
- spans three
- lines.
-```
-
-The Scala library contains a utility method `stripMargin`
-which can be used to strip leading whitespace from multi-line strings.
-The expression
-
-```scala
- """the present string
- |spans three
- |lines.""".stripMargin
-```
-
-evaluates to
-
-```scala
-the present string
-spans three
-lines.
-```
-
-Method `stripMargin` is defined in class
-[scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/#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.
+> ```scala
+> """the present string
+> spans three
+> lines."""
+> ```
+>
+> This would produce the string:
+>
+> ```scala
+> the present string
+> spans three
+> lines.
+> ```
+>
+> The Scala library contains a utility method `stripMargin`
+> which can be used to strip leading whitespace from multi-line strings.
+> The expression
+>
+> ```scala
+> """the present string
+> |spans three
+> |lines.""".stripMargin
+> ```
+>
+> evaluates to
+>
+> ```scala
+> the present string
+> spans three
+> lines.
+> ```
+>
+> Method `stripMargin` is defined in class
+> [scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/#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
@@ -587,15 +573,13 @@ The scanner switches from XML mode to Scala mode if either
Note that no Scala tokens are constructed in XML mode, and that comments are interpreted
as text.
-### Example
-
-The following value definition uses an XML literal with two embedded
-Scala expressions:
-
-```scala
-val b = <book>
- <title>The Scala Language Specification</title>
- <version>{scalaBook.version}</version>
- <authors>{scalaBook.authors.mkList("", ", ", "")}</authors>
- </book>
-```
+> The following value definition uses an XML literal with two embedded
+> Scala expressions:
+>
+> ```scala
+> val b = <book>
+> <title>The Scala Language Specification</title>
+> <version>{scalaBook.version}</version>
+> <authors>{scalaBook.authors.mkList("", ", ", "")}</authors>
+> </book>
+> ```
diff --git a/spec/02-identifiers-names-and-scopes.md b/spec/02-identifiers-names-and-scopes.md
index 62d326934f..0a9c5dfe77 100644
--- a/spec/02-identifiers-names-and-scopes.md
+++ b/spec/02-identifiers-names-and-scopes.md
@@ -1,5 +1,5 @@
---
-title: Identifiers, Names and Scopes
+title: Identifiers, Names & Scopes
layout: default
chapter: 2
---
@@ -69,7 +69,7 @@ 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
+###### Example
Assume the following two definitions of objects named `X` in packages `P` and `Q`.
diff --git a/spec/03-types.md b/spec/03-types.md
index 5658e15f44..9741286a5d 100644
--- a/spec/03-types.md
+++ b/spec/03-types.md
@@ -147,7 +147,7 @@ A qualified type designator has the form `p.t` where `p` is
a [path](#paths) and _t_ is a type name. Such a type designator is
equivalent to the type projection `p.type#t`.
-### Example
+###### Example
Some type designators and their expansions are listed below. We assume
a local type parameter $t$, a value `maintable`
@@ -178,7 +178,8 @@ well-formed if each actual type parameter
_conforms to its bounds_, i.e. $\sigma L_i <: T_i <: \sigma U_i$ where $\sigma$ is the
substitution $[ a_1 := T_1 , \ldots , a_n := T_n ]$.
-### Example Parameterized Types
+###### Example Parameterized Types
+
Given the partial type definitions:
```scala
@@ -202,7 +203,7 @@ F[List, Int]
G[S, String]
```
-### Example
+###### Example
Given the [above type definitions](#example-parameterized-types),
the following types are ill-formed:
@@ -255,10 +256,10 @@ AnnotType ::= SimpleType {Annotation}
```
An annotated type $T$ $a_1, \ldots, a_n$
-attaches [annotations](11-user-defined-annotations.html#user-defined-annotations)
+attaches [annotations](11-annotations.html#user-defined-annotations)
$a_1 , \ldots , a_n$ to the type $T$.
-### Example
+###### Example
The following type adds the `@suspendable` annotation to the type `String`:
@@ -304,7 +305,7 @@ A compound type may also consist of just a refinement
$\\{ R \\}$ with no preceding component types. Such a type is
equivalent to `AnyRef` $\\{ R \\}$.
-### Example
+###### Example
The following example shows how to declare and use a method which
a parameter type that contains a refinement with structural declarations.
@@ -500,7 +501,7 @@ or [tuple types](#tuple-types).
Their expansion is then the expansion in the equivalent parameterized
type.
-### Example
+###### Example
Assume the class definitions
@@ -524,7 +525,7 @@ An alternative formulation of the first type above using wildcard syntax is:
Ref[_ <: java.lang.Number]
```
-### Example
+###### Example
The type `List[List[_]]` is equivalent to the existential type
@@ -532,7 +533,7 @@ The type `List[List[_]]` is equivalent to the existential type
List[List[t] forSome { type t }] .
```
-### Example
+###### Example
Assume a covariant type
@@ -658,7 +659,7 @@ same name, we model
An overloaded type consisting of type alternatives $T_1 \commadots T_n (n \geq 2)$ is denoted internally $T_1 \overload \ldots \overload T_n$.
-### Example
+###### Example
```
def println: Unit
def println(s: String): Unit = $\ldots$
@@ -676,7 +677,7 @@ println: => Unit $\overload$
[A] (A) (A => String) Unit
```
-### Example
+###### Example
```
def f(x: T): T = $\ldots$
val f = 0
diff --git a/spec/04-basic-declarations-and-definitions.md b/spec/04-basic-declarations-and-definitions.md
index 65d79dd5f4..7fb5427d36 100644
--- a/spec/04-basic-declarations-and-definitions.md
+++ b/spec/04-basic-declarations-and-definitions.md
@@ -1,5 +1,5 @@
---
-title: Basic Declarations and Definitions
+title: Basic Declarations & Definitions
layout: default
chapter: 4
---
@@ -563,7 +563,7 @@ abstract class Sequence[+A] {
}
```
-### Example
+###### Example
```scala
abstract class OutputChannel[-A] {
diff --git a/spec/05-classes-and-objects.md b/spec/05-classes-and-objects.md
index 8681c93193..a6908ba39f 100644
--- a/spec/05-classes-and-objects.md
+++ b/spec/05-classes-and-objects.md
@@ -1,5 +1,5 @@
---
-title: Classes and Objects
+title: Classes & Objects
layout: default
chapter: 5
---
@@ -368,7 +368,7 @@ it is possible to add new defaults (if the corresponding parameter in the
superclass does not have a default) or to override the defaults of the
superclass (otherwise).
-### Example
+###### Example
Consider the definitions:
@@ -699,7 +699,7 @@ Here,
parameter section is called _polymorphic_, otherwise it is called
_monomorphic_.
- $as$ is a possibly empty sequence of
- [annotations](11-user-defined-annotations.html#user-defined-annotations).
+ [annotations](11-annotations.html#user-defined-annotations).
If any annotations are given, they apply to the primary constructor of the
class.
- $m$ is an [access modifier](#modifiers) such as
@@ -744,7 +744,7 @@ which when applied to parameters conforming to types $\mathit{ps}$
initializes instances of type `$c$[$\mathit{tps}\,$]` by evaluating the template
$t$.
-### Example
+###### Example
The following example illustrates `val` and `var` parameters of a class `C`:
```scala
@@ -990,7 +990,7 @@ it is not statically known at the time the trait is defined.
If $D$ is not a trait, then its actual supertype is simply its
least proper supertype (which is statically known).
-### Example
+###### Example
The following trait defines the property
of being comparable to objects of some type. It contains an abstract
method `<` and default implementations of the other
diff --git a/spec/06-expressions.md b/spec/06-expressions.md
index 133ec3c8e5..db206631a8 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -205,7 +205,7 @@ to the type or method of $x$ in the parent trait of $C$ whose simple
name is $T$. That member must be uniquely defined. If it is a method,
it must be concrete.
-### Example
+###### Example
Consider the following class definitions
```scala
@@ -778,7 +778,7 @@ 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
+attaches [annotations](11-annotations.html#user-defined-annotations) $a_1 , \ldots , a_n$ to the
expression $e$.
## Assignments
@@ -815,7 +815,7 @@ Here are some assignment expressions and their equivalent expansions.
|`x.f(i) = e` | `x.f.update(i, e)` |
|`x.f(i, j) = e` | `x.f.update(i, j, e)`|
-### Example Imperative Matrix Multiplication
+###### Example Imperative Matrix Multiplication
Here is the usual imperative code for matrix multiplication.
@@ -1221,9 +1221,9 @@ In that case, a fresh name for the parameter is chosen arbitrarily.
A named parameter of an anonymous function may be optionally preceded
by an `implicit` modifier. In that case the parameter is
-labeled [`implicit`](07-implicit-parameters-and-views.html#implicit-parameters-and-views); however the
+labeled [`implicit`](07-implicits.html#implicit-parameters-and-views); however the
parameter section itself does not count as an implicit parameter
-section in the sense defined [here](07-implicit-parameters-and-views.html#implicit-parameters). Hence, arguments to
+section in the sense defined [here](07-implicits.html#implicit-parameters). Hence, arguments to
anonymous functions always have to be given explicitly.
###### Example
@@ -1341,7 +1341,7 @@ 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
-[view applications](07-implicit-parameters-and-views.html#views).
+[view applications](07-implicits.html#views).
### Value Conversions
@@ -1389,7 +1389,7 @@ term `{ $e$; () }`.
###### View Application
If none of the previous conversions applies, and $e$'s type
does not conform to the expected type $\mathit{pt}$, it is attempted to convert
-$e$ to the expected type with a [view](07-implicit-parameters-and-views.html#views).
+$e$ to the expected type with a [view](07-implicits.html#views).
###### Dynamic Member Selection
If none of the previous conversions applies, and $e$ is a prefix
@@ -1408,7 +1408,7 @@ type $T$ by evaluating the expression to which $m$ is bound.
###### Implicit Application
If the method takes only implicit parameters, implicit
-arguments are passed following the rules [here](07-implicit-parameters-and-views.html#implicit-parameters).
+arguments are passed following the rules [here](07-implicits.html#implicit-parameters).
###### Eta Expansion
Otherwise, if the method is not a constructor,
diff --git a/spec/07-implicit-parameters-and-views.md b/spec/07-implicits.md
index 27a50cf058..5e10373959 100644
--- a/spec/07-implicit-parameters-and-views.md
+++ b/spec/07-implicits.md
@@ -1,10 +1,10 @@
---
-title: Implicit Parameters and Views
+title: Implicits
layout: default
chapter: 7
---
-# Implicit Parameters and Views
+# Implicits
## The Implicit Modifier
@@ -19,7 +19,8 @@ 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).
-### Example Monoid
+###### Example Monoid
+
The following code defines an abstract class of monoids and
two concrete implementations, `StringMonoid` and
`IntMonoid`. The two implementations are marked implicit.
@@ -180,7 +181,7 @@ 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_
-of $T$ is $T$ with aliases expanded, top-level type [annotations](11-user-defined-annotations.html#user-defined-annotations) and
+of $T$ is $T$ with aliases expanded, top-level type [annotations](11-annotations.html#user-defined-annotations) and
[refinements](03-types.html#compound-types) removed, and occurrences
of top-level existentially bound variables replaced by their upper
bounds. The core type is removed from the stack once the search for
@@ -284,7 +285,8 @@ As for implicit parameters, overloading resolution is applied
if there are several possible candidates (of either the call-by-value
or the call-by-name category).
-### Example Ordered
+###### Example Ordered
+
Class `scala.Ordered[A]` contains a method
```scala
diff --git a/spec/08-pattern-matching.md b/spec/08-pattern-matching.md
index e75bddc096..c494fbcef5 100644
--- a/spec/08-pattern-matching.md
+++ b/spec/08-pattern-matching.md
@@ -371,7 +371,7 @@ 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.
+### Type parameter inference for typed patterns
Assume a typed pattern $p: T'$. Let $T$ result from $T'$ where all wildcards in
$T'$ are renamed to fresh variable names. Let $a_1 , \ldots , a_n$ be
@@ -437,7 +437,7 @@ complexity of inferred bounds. Minimality and maximality of types have
to be understood relative to the set of types of acceptable
complexity.
-#### Type parameter inference for constructor patterns.
+### Type parameter inference for constructor patterns
Assume a constructor pattern $C(p_1 , \ldots , p_n)$ where class $C$
has type type parameters $a_1 , \ldots , a_n$. These type parameters
are inferred in the same way as for the typed pattern
@@ -593,7 +593,7 @@ 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.
-### Example
+###### Example
Consider the following definitions of arithmetic terms:
diff --git a/spec/10-xml-expressions-and-patterns.md b/spec/10-xml-expressions-and-patterns.md
index 407b2b9a67..b70fb86471 100644
--- a/spec/10-xml-expressions-and-patterns.md
+++ b/spec/10-xml-expressions-and-patterns.md
@@ -1,5 +1,5 @@
---
-title: XML Expressions and Patterns
+title: XML
layout: default
chapter: 10
---
diff --git a/spec/11-user-defined-annotations.md b/spec/11-annotations.md
index 2c5830c103..d66f24abf8 100644
--- a/spec/11-user-defined-annotations.md
+++ b/spec/11-annotations.md
@@ -1,17 +1,19 @@
---
-title: User-Defined Annotations
+title: Annotations
layout: default
chapter: 11
---
-# User-Defined Annotations
+# Annotations
```ebnf
Annotation ::= ‘@’ SimpleType {ArgumentExprs}
ConstrAnnotation ::= ‘@’ SimpleType ArgumentExprs
```
-User-defined annotations associate meta-information with definitions.
+## Definition
+
+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`.
@@ -33,6 +35,10 @@ String @local // Type annotation
(e: @unchecked) match { ... } // Expression annotation
```
+## Predefined Annotations
+
+### Java Platform Annotations
+
The meaning of annotation clauses is implementation-dependent. On the
Java platform, the following annotations have a standard meaning.
@@ -61,7 +67,7 @@ Java platform, the following annotations have a standard meaning.
clause for the method or constructor must mention the class of that exception
or one of the superclasses of the class of that exception.
-## Java Beans Annotations
+### Java Beans Annotations
* `@scala.beans.BeanProperty` When prefixed to a definition of some variable `X`, this
annotation causes getter and setter methods `getX`, `setX`
@@ -76,18 +82,21 @@ Java platform, the following annotations have a standard meaning.
* `@scala.beans.BooleanBeanProperty` This annotation is equivalent to `scala.reflect.BeanProperty`, but
the generated getter method is named `isX` instead of `getX`.
-## Deprecation Annotations
+### Deprecation Annotations
- * `@deprecated(<stringlit>)` Marks a definition as deprecated. Accesses to the
+ * `@deprecated(message: <stringlit>, since: <stringlit>)`<br/>
+ Marks a definition as deprecated. Accesses to the
defined entity will then cause a deprecated warning mentioning the
- message `<stringlit>` to be issued from the compiler. Deprecated
- warnings are suppressed in code that belongs itself to a definition
+ _message_ `<stringlit>` to be issued from the compiler.
+ The argument _since_ documents since when the definition should be considered deprecated.<br/>
+ Deprecated warnings are suppressed in code that belongs itself to a definition
that is labeled deprecated.
- * `@deprecatedName(name: <symbollit>)` Marks a formal parameter name as deprecated. Invocations of this entity
+ * `@deprecatedName(name: <symbollit>)`<br/>
+ Marks a formal parameter name as deprecated. Invocations of this entity
using named parameter syntax refering to the deprecated parameter name cause a deprecation warning.
-## Scala Compiler Annotations
+### Scala Compiler Annotations
* `@unchecked` When applied to the selector of a `match` expression,
this attribute suppresses any warnings about non-exhaustive pattern
@@ -141,6 +150,8 @@ 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.
+## User-defined Annotations
+
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
diff --git a/spec/12-the-scala-standard-library.md b/spec/12-the-scala-standard-library.md
index 988d9804ec..e76035f458 100644
--- a/spec/12-the-scala-standard-library.md
+++ b/spec/12-the-scala-standard-library.md
@@ -1,5 +1,5 @@
---
-title: The Scala Standard Library
+title: Standard Library
layout: default
chapter: 12
---
@@ -233,7 +233,7 @@ for type `Int` and for all subrange types.
The `toString` method displays its receiver as an integer or
floating point number.
-### Example
+###### Example
This is the signature of the numeric value type `Int`:
@@ -332,7 +332,7 @@ The `toString` method returns `"()"`.
## Standard Reference Classes
This section presents some standard Scala reference classes which are
-treated in a special way by the Scala compiler -- either Scala provides
+treated in a special way by the Scala compiler – either Scala provides
syntactic sugar for them, or the Scala compiler generates special code
for their operations. Other classes in the standard Scala library are
documented in the Scala library documentation by HTML pages.
diff --git a/spec/13-syntax-summary.md b/spec/13-syntax-summary.md
index 2b9571cc73..7f73e107de 100644
--- a/spec/13-syntax-summary.md
+++ b/spec/13-syntax-summary.md
@@ -15,6 +15,8 @@ UnicodeEscape ::= ‘\‘ ‘u‘ {‘u‘} hexDigit hexDigit hexDigit hexDigit
hexDigit ::= ‘0’ | … | ‘9’ | ‘A’ | … | ‘F’ | ‘a’ | … | ‘f’
```
+## Lexical Syntax
+
The lexical syntax of Scala is given by the following grammar in EBNF form:
```ebnf
@@ -72,8 +74,10 @@ nl ::= $\mathit{“new line character”}$
semi ::= ‘;’ | nl {nl}
```
+## Context-free Syntax
+
The context-free syntax of Scala is given by the following EBNF
-grammar.
+grammar:
```ebnf
Literal ::= [‘-’] integerLiteral
diff --git a/spec/15-changelog.md b/spec/15-changelog.md
new file mode 100644
index 0000000000..54310c921c
--- /dev/null
+++ b/spec/15-changelog.md
@@ -0,0 +1,823 @@
+---
+title: Changelog
+layout: default
+chapter: 15
+---
+
+# Changelog
+
+Changes in Version 2.8.0
+------------------------
+
+#### Trailing commas
+
+Trailing commas in expression, argument, type or pattern sequences are
+no longer supported.
+
+Changes in Version 2.8
+----------------------
+
+Changed visibility rules for nested packages (where done?)
+
+Changed [visibility rules](02-identifiers-names-and-scopes.html)
+so that packages are no longer treated specially.
+
+Added section on [weak conformance](03-types.html#weak-conformance).
+Relaxed type rules for conditionals,
+match expressions, try expressions to compute their result type using
+least upper bound wrt weak conformance. Relaxed type rule for local type
+inference so that argument types need only weekly conform to inferred
+formal parameter types. Added section on
+[numeric widening](06-expressions.html#numeric-widening) to support
+weak conformance.
+
+Tightened rules to avoid accidential [overrides](05-classes-and-objects.html#overriding).
+
+Removed class literals.
+
+Added section on [context bounds](07-implicits.html#context-bounds-and-view-bounds).
+
+Clarified differences between [`isInstanceOf` and pattern matches](12-the-scala-standard-library.html#root-classes).
+
+Allowed [`implicit` modifier on function literals](06-expressions.html#anonymous-functions) with a single parameter.
+
+Changes in Version 2.7.2
+------------------------
+
+_(10-Nov-2008)_
+
+#### Precedence of Assignment Operators
+
+The [precedence of assignment operators](06-expressions.html#prefix,-infix,-and-postfix-operations)
+has been brought in line with. From now on `+=`, has the same precedence as `=`.
+
+#### Wildcards as function parameters
+
+A formal parameter to an anonymous fucntion may now be a
+[wildcard represented by an underscore](06-expressions.html#placeholder-syntax-for-anonymous-functions).
+
+> _ => 7 // The function that ignores its argument
+> // and always returns 7.
+
+#### Unicode alternative for left arrow
+
+The Unicode glyph ‘\\(\leftarrow\\)’ \\(`\u2190`\\) is now treated as a reserved
+identifier, equivalent to the ASCII symbol ‘`<-`’.
+
+Changes in Version 2.7.1
+------------------------
+
+_(09-April-2008)_
+
+#### Change in Scoping Rules for Wildcard Placeholders in Types
+
+A wildcard in a type now binds to the closest enclosing type
+application. For example `List[List[_]]` is now equivalent to this
+existential type:
+
+ List[List[t] forSome { type t }]
+
+In version 2.7.0, the type expanded instead to:
+
+ List[List[t]] forSome { type t }
+
+The new convention corresponds exactly to the way wildcards in Java are
+interpreted.
+
+#### No Contractiveness Requirement for Implicits
+
+The contractiveness requirement for
+[implicit method definitions](07-implicits.html#implicit-parameters)
+has been dropped. Instead it is checked for each implicit expansion individually
+that the expansion does not result in a cycle or a tree of infinitely
+growing types.
+
+Changes in Version 2.7.0
+------------------------
+
+_(07-Feb-2008)_
+
+#### Java Generics
+
+Scala now supports Java generic types by default:
+
+- A generic type in Java such as `ArrayList<String>` is translated to
+ a generic type in Scala: `ArrayList[String]`.
+
+- A wildcard type such as `ArrayList<? extends Number>` is translated
+ to `ArrayList[_ <: Number]`. This is itself a shorthand for the
+ existential type `ArrayList[T] forSome { type T <: Number }`.
+
+- A raw type in Java such as `ArrayList` is translated to
+ `ArrayList[_]`, which is a shorthand for
+ `ArrayList[T] forSome { type T }`.
+
+This translation works if `-target:jvm-1.5` is specified, which is the
+new default. For any other target, Java generics are not recognized. To
+ensure upgradability of Scala codebases, extraneous type parameters for
+Java classes under `-target:jvm-1.4` are simply ignored. For instance,
+when compiling with `-target:jvm-1.4`, a Scala type such as
+`ArrayList[String]` is simply treated as the unparameterized type
+`ArrayList`.
+
+#### Changes to Case Classes
+
+The Scala compiler generates now for every case class a companion
+extractor object (). For instance, given the case class:
+
+ case class X(elem: String)
+
+the following companion object is generated:
+
+ object X {
+ def unapply(x: X): Some[String] = Some(x.elem)
+ def apply(s: String): X = new X(s)
+ }
+
+If the object exists already, only the `apply` and `unapply` methods are
+added to it.
+
+Three restrictions on case classes have been removed.
+
+1. Case classes can now inherit from other case classes.
+
+2. Case classes may now be `abstract`.
+
+3. Case classes may now come with companion objects.
+
+Changes in Version 2.6.1
+------------------------
+
+_(30-Nov-2007)_
+
+#### Mutable variables introduced by pattern binding
+
+Mutable variables can now be introduced by a pattern matching definition
+(), just like values can. Examples:
+
+ var (x, y) = if (positive) (1, 2) else (-1, -3)
+ var hd :: tl = mylist
+
+#### Self-types
+
+Self types can now be introduced without defining an alias name for
+`this` (). Example:
+
+ class C {
+ type T <: Trait
+ trait Trait { this: T => ... }
+ }
+
+Changes in Version 2.6
+----------------------
+
+_(27-July-2007)_
+
+#### Existential types
+
+It is now possible to define existential types (). An existential type
+has the form `T forSome {Q}` where `Q` is a sequence of value and/or
+type declarations. Given the class definitions
+
+ class Ref[T]
+ abstract class Outer { type T }
+
+one may for example write the following existential types
+
+ Ref[T] forSome { type T <: java.lang.Number }
+ Ref[x.T] forSome { val x: Outer }
+
+#### Lazy values
+
+It is now possible to define lazy value declarations using the new
+modifier `lazy` (). A `lazy` value definition evaluates its right hand
+side \\(e\\) the first time the value is accessed. Example:
+
+ import compat.Platform._
+ val t0 = currentTime
+ lazy val t1 = currentTime
+ val t2 = currentTime
+
+ println("t0 <= t2: " + (t0 <= t2)) //true
+ println("t1 <= t2: " + (t1 <= t2)) //false (lazy evaluation of t1)
+
+#### Structural types
+
+It is now possible to declare structural types using type refinements
+(). For example:
+
+ class File(name: String) {
+ def getName(): String = name
+ def open() { /*..*/ }
+ def close() { println("close file") }
+ }
+ def test(f: { def getName(): String }) { println(f.getName) }
+
+ test(new File("test.txt"))
+ test(new java.io.File("test.txt"))
+
+There’s also a shorthand form for creating values of structural types.
+For instance,
+
+ new { def getName() = "aaron" }
+
+is a shorthand for
+
+ new AnyRef{ def getName() = "aaron" }
+
+Changes in Version 2.5
+----------------------
+
+_(02-May-2007)_
+
+#### Type constructor polymorphism[^1]
+
+Type parameters () and abstract type members () can now also abstract
+over type constructors ().
+
+This allows a more precise `Iterable` interface:
+
+ trait Iterable[+T] {
+ type MyType[+T] <: Iterable[T] // MyType is a type constructor
+
+ def filter(p: T => Boolean): MyType[T] = ...
+ def map[S](f: T => S): MyType[S] = ...
+ }
+
+ abstract class List[+T] extends Iterable[T] {
+ type MyType[+T] = List[T]
+ }
+
+This definition of `Iterable` makes explicit that mapping a function
+over a certain structure (e.g., a `List`) will yield the same structure
+(containing different elements).
+
+#### Early object initialization
+
+It is now possible to initialize some fields of an object before any
+parent constructors are called (). This is particularly useful for
+traits, which do not have normal constructor parameters. Example:
+
+ trait Greeting {
+ val name: String
+ val msg = "How are you, "+name
+ }
+ class C extends {
+ val name = "Bob"
+ } with Greeting {
+ println(msg)
+ }
+
+In the code above, the field is initialized before the constructor of is
+called. Therefore, field `msg` in class is properly initialized to .
+
+#### For-comprehensions, revised
+
+The syntax of for-comprehensions has changed (). In the new syntax,
+generators do not start with a anymore, but filters start with an (and
+are called guards). A semicolon in front of a guard is optional. For
+example:
+
+ for (val x <- List(1, 2, 3); x % 2 == 0) println(x)
+
+is now written
+
+ for (x <- List(1, 2, 3) if x % 2 == 0) println(x)
+
+The old syntax is still available but will be deprecated in the future.
+
+#### Implicit anonymous functions
+
+It is now possible to define anonymous functions using underscores in
+parameter position (). For instance, the expressions in the left column
+are each function values which expand to the anonymous functions on
+their right.
+
+ _ + 1 x => x + 1
+ _ * _ (x1, x2) => x1 * x2
+ (_: int) * 2 (x: int) => (x: int) * 2
+ if (_) x else y z => if (z) x else y
+ _.map(f) x => x.map(f)
+ _.map(_ + 1) x => x.map(y => y + 1)
+
+As a special case (), a partially unapplied method is now designated
+ `m _`   instead of the previous notation  `&m`.
+
+The new notation will displace the special syntax forms `.m()` for
+abstracting over method receivers and `&m` for treating an unapplied
+method as a function value. For the time being, the old syntax forms are
+still available, but they will be deprecated in the future.
+
+#### Pattern matching anonymous functions, refined
+
+It is now possible to use case clauses to define a function value
+directly for functions of arities greater than one (). Previously, only
+unary functions could be defined that way. Example:
+
+ def scalarProduct(xs: Array[Double], ys: Array[Double]) =
+ (0.0 /: (xs zip ys)) {
+ case (a, (b, c)) => a + b * c
+ }
+
+Changes in Version 2.4
+----------------------
+
+_(09-Mar-2007)_
+
+#### Object-local private and protected
+
+The `private` and `protected` modifiers now accept a `[this]` qualifier
+(). A definition \\(M\\) which is labelled `private[this]` is private,
+and in addition can be accessed only from within the current object.
+That is, the only legal prefixes for \\(M\\) are `this` or `$C$.this`.
+Analogously, a definition \\(M\\) which is labelled `protected[this]` is
+protected, and in addition can be accessed only from within the current
+object.
+
+#### Tuples, revised
+
+The syntax for [tuples](06-expressions.html#tuples) has been changed from \\(\\{…\\}\\) to
+\\((…)\\). For any sequence of types \\(T_1 , … , T_n\\),
+
+\\((T_1 , … , T_n)\\) is a shorthand for `Tuple$n$[$T_1 , … , T_n$]`.
+
+Analogously, for any sequence of expressions or patterns \\(x_1
+, … , x_n\\),
+
+\\((x_1 , … , x_n)\\) is a shorthand for `Tuple$n$($x_1 , … , x_n$)`.
+
+#### Access modifiers for primary constructors
+
+The primary constructor of a class can now be marked or (). If such an
+access modifier is given, it comes between the name of the class and its
+value parameters. Example:
+
+ class C[T] private (x: T) { ... }
+
+#### Annotations
+
+The support for attributes has been extended and its syntax changed ().
+Attributes are now called <span>*annotations*</span>. The syntax has
+been changed to follow Java’s conventions, e.g. `@attribute` instead of
+`[attribute]`. The old syntax is still available but will be deprecated
+in the future.
+
+Annotations are now serialized so that they can be read by compile-time
+or run-time tools. Class has two sub-traits which are used to indicate
+how annotations are retained. Instances of an annotation class
+inheriting from trait will be stored in the generated class files.
+Instances of an annotation class inheriting from trait will be visible
+to the Scala type-checker in every compilation unit where the annotated
+symbol is accessed.
+
+#### Decidable subtyping
+
+The implementation of subtyping has been changed to prevent infinite
+recursions. Termination of subtyping is now ensured by a new restriction
+of class graphs to be finitary ().
+
+#### Case classes cannot be abstract
+
+It is now explicitly ruled out that case classes can be abstract (). The
+specification was silent on this point before, but did not explain how
+abstract case classes were treated. The Scala compiler allowed the
+idiom.
+
+#### New syntax for self aliases and self types
+
+It is now possible to give an explicit alias name and/or type for the
+self reference (). For instance, in
+
+ class C { self: D =>
+ ...
+ }
+
+the name is introduced as an alias for within and the self type () of is
+assumed to be . This construct is introduced now in order to replace
+eventually both the qualified this construct and the clause in Scala.
+
+#### Assignment Operators
+
+It is now possible to combine operators with assignments (). Example:
+
+ var x: int = 0
+ x += 1
+
+Changes in Version 2.3.2
+------------------------
+
+_(23-Jan-2007)_
+
+#### Extractors
+
+It is now possible to define patterns independently of case classes,
+using methods in extractor objects (). Here is an example:
+
+ object Twice {
+ def apply(x:Int): int = x*2
+ def unapply(z:Int): Option[int] = if (z%2==0) Some(z/2) else None
+ }
+ val x = Twice(21)
+ x match { case Twice(n) => Console.println(n) } // prints 21
+
+In the example, `Twice` is an extractor object with two methods:
+
+- The method is used to build even numbers.
+
+- The method is used to decompose an even number; it is in a sense the
+ reverse of . `unapply` methods return option types: for a match that
+ suceeds, for a match that fails. Pattern variables are returned as
+ the elements of . If there are several variables, they are grouped
+ in a tuple.
+
+In the second-to-last line, ’s method is used to construct a number . In
+the last line, is tested against the pattern . This pattern succeeds for
+even numbers and assigns to the variable one half of the number that was
+tested. The pattern match makes use of the method of object . More
+details on extractors can be found in the paper “Matching Objects with
+Patterns” by Emir, Odersky and Williams.
+
+#### Tuples
+
+A new lightweight syntax for tuples has been introduced (). For any
+sequence of types \\(T_1 , … , T_n\\),
+
+\\(\{T_1 , … , T_n \}\\) is a shorthand for `Tuple$n$[$T_1 , … , T_n$]`.
+
+Analogously, for any sequence of expressions or patterns \\(x_1, … , x_n\\),
+
+\\(\{x_1 , … , x_n \}\\) is a shorthand for `Tuple$n$($x_1 , … , x_n$)`.
+
+#### Infix operators of greater arities
+
+It is now possible to use methods which have more than one parameter as
+infix operators (). In this case, all method arguments are written as a
+normal parameter list in parentheses. Example:
+
+ class C {
+ def +(x: int, y: String) = ...
+ }
+ val c = new C
+ c + (1, "abc")
+
+#### Deprecated attribute
+
+A new standard attribute `deprecated` is available (11-annotations.html#deprecation-annotations). If a member
+definition is marked with this attribute, any reference to the member
+will cause a “deprecated” warning message to be emitted.
+
+Changes in Version 2.3
+----------------------
+
+_(23-Nov-2006)_
+
+#### Procedures
+
+A simplified syntax for functions returning `unit` has been introduced
+(). Scala now allows the following shorthands:
+
+`def f(params)` \\(\mbox{for}\\) `def f(params): unit`
+`def f(params) { ... }` \\(\mbox{for}\\) `def f(params): unit = { ... }`
+
+#### Type Patterns
+
+The syntax of types in patterns has been refined (). Scala now
+distinguishes between type variables (starting with a lower case letter)
+and types as type arguments in patterns. Type variables are bound in the
+pattern. Other type arguments are, as in previous versions, erased. The
+Scala compiler will now issue an “unchecked” warning at places where
+type erasure might compromise type-safety.
+
+#### Standard Types
+
+The recommended names for the two bottom classes in Scala’s type
+hierarchy have changed as follows:
+
+ All ==> Nothing
+ AllRef ==> Null
+
+The old names are still available as type aliases.
+
+Changes in Version 2.1.8
+------------------------
+
+_(23-Aug-2006)_
+
+#### Visibility Qualifier for protected
+
+Protected members can now have a visibility qualifier (), e.g.
+`protected[<qualifier>]`. In particular, one can now simulate package
+protected access as in Java writing
+
+ protected[P] def X ...
+
+where would name the package containing .
+
+#### Relaxation of Private Acess
+
+Private members of a class can now be referenced from the companion
+module of the class and vice versa ()
+
+#### Implicit Lookup
+
+The lookup method for implicit definitions has been generalized (). When
+searching for an implicit definition matching a type \\(T\\), now are
+considered
+
+1. all identifiers accessible without prefix, and
+
+2. all members of companion modules of classes associated with \\(T\\).
+
+(The second clause is more general than before). Here, a class is
+<span>*associated*</span> with a type \\(T\\) if it is referenced by
+some part of \\(T\\), or if it is a base class of some part of \\(T\\).
+For instance, to find implicit members corresponding to the type
+
+ HashSet[List[Int], String]
+
+one would now look in the companion modules (aka static parts) of , , ,
+and . Before, it was just the static part of .
+
+#### Tightened Pattern Match
+
+A typed pattern match with a singleton type now tests whether the
+selector value is reference-equal to p (). Example:
+
+ val p = List(1, 2, 3)
+ val q = List(1, 2)
+ val r = q
+ r match {
+ case _: p.type => Console.println("p")
+ case _: q.type => Console.println("q")
+ }
+
+This will match the second case and hence will print “”. Before, the
+singleton types were erased to , and therefore the first case would have
+matched, which is non-sensical.
+
+Changes in Version 2.1.7
+------------------------
+
+_(19-Jul-2006)_
+
+#### Multi-Line string literals
+
+It is now possible to write multi-line string-literals enclosed in
+triple quotes (). Example:
+
+ """this is a
+ multi-line
+ string literal"""
+
+No escape substitutions except for unicode escapes are performed in such
+string literals.
+
+#### Closure Syntax
+
+The syntax of closures has been slightly restricted (). The form
+
+ x: T => E
+
+is valid only when enclosed in braces, i.e.  `{ x: T => E }`. The
+following is illegal, because it might be read as the value x typed with
+the type T =\> E:
+
+ val f = x: T => E
+
+Legal alternatives are:
+
+ val f = { x: T => E }
+ val f = (x: T) => E
+
+Changes in Version 2.1.5
+------------------------
+
+_(24-May-2006)_
+
+#### Class Literals
+
+There is a new syntax for class literals (): For any class type \\(C\\),
+`classOf[$C$]` designates the run-time representation of \\(C\\).
+
+Changes in Version 2.0
+----------------------
+
+_(12-Mar-2006)_
+
+Scala in its second version is different in some details from the first
+version of the language. There have been several additions and some old
+idioms are no longer supported. This appendix summarizes the main
+changes.
+
+#### New Keywords
+
+The following three words are now reserved; they cannot be used as
+identifiers ()
+
+ implicit match requires
+
+#### Newlines as Statement Separators
+
+Newlines can now be used as statement separators in place of semicolons
+()
+
+#### Syntax Restrictions
+
+There are some other situations where old constructs no longer work:
+
+##### *Pattern matching expressions*
+
+The `match` keyword now appears only as infix operator between a
+selector expression and a number of cases, as in:
+
+ expr match {
+ case Some(x) => ...
+ case None => ...
+ }
+
+Variants such as ` expr.match {...} ` or just ` match {...} ` are no
+longer supported.
+
+##### *“With” in extends clauses*
+
+The idiom
+
+ class C with M { ... }
+
+is no longer supported. A `with` connective is only allowed following an
+`extends` clause. For instance, the line above would have to be written
+
+ class C extends AnyRef with M { ... } .
+
+However, assuming `M` is a trait (see [sec:traits]), it is also legal to
+write
+
+ class C extends M { ... }
+
+The latter expression is treated as equivalent to
+
+ class C extends S with M { ... }
+
+where `S` is the superclass of `M`.
+
+##### *Regular Expression Patterns*
+
+The only form of regular expression pattern that is currently supported
+is a sequence pattern, which might end in a sequence wildcard . Example:
+
+ case List(1, 2, _*) => ... // will match all lists starting with \code{1,2}.
+
+It is at current not clear whether this is a permanent restriction. We
+are evaluating the possibility of re-introducing full regular expression
+patterns in Scala.
+
+#### Selftype Annotations
+
+The recommended syntax of selftype annotations has changed.
+
+ class C: T extends B { ... }
+
+becomes
+
+ class C requires T extends B { ... }
+
+That is, selftypes are now indicated by the new `requires` keyword. The
+old syntax is still available but is considered deprecated.
+
+#### For-comprehensions
+
+For-comprehensions () now admit value and pattern definitions. Example:
+
+ for {
+ val x <- List.range(1, 100)
+ val y <- List.range(1, x)
+ val z = x + y
+ isPrime(z)
+ } yield Pair(x, y)
+
+Note the definition  `val z = x + y` as the third item in the
+for-comprehension.
+
+#### Conversions
+
+The rules for implicit conversions of methods to functions () have been
+tightened. Previously, a parameterized method used as a value was always
+implicitly converted to a function. This could lead to unexpected
+results when method arguments where forgotten. Consider for instance the
+statement below:
+
+ show(x.toString)
+
+where `show` is defined as follows:
+
+ def show(x: String) = Console.println(x) .
+
+Most likely, the programmer forgot to supply an empty argument list `()`
+to `toString`. The previous Scala version would treat this code as a
+partially applied method, and expand it to:
+
+ show(() => x.toString())
+
+As a result, the address of a closure would be printed instead of the
+value of `s`.
+
+Scala version 2.0 will apply a conversion from partially applied method
+to function value only if the expected type of the expression is indeed
+a function type. For instance, the conversion would not be applied in
+the code above because the expected type of `show`’s parameter is
+`String`, not a function type.
+
+The new convention disallows some previously legal code. Example:
+
+ def sum(f: int => double)(a: int, b: int): double =
+ if (a > b) 0 else f(a) + sum(f)(a + 1, b)
+
+ val sumInts = sum(x => x) // error: missing arguments
+
+The partial application of `sum` in the last line of the code above will
+not be converted to a function type. Instead, the compiler will produce
+an error message which states that arguments for method `sum` are
+missing. The problem can be fixed by providing an expected type for the
+partial application, for instance by annotating the definition of
+`sumInts` with its type:
+
+ val sumInts: (int, int) => double = sum(x => x) // OK
+
+On the other hand, Scala version 2.0 now automatically applies methods
+with empty parameter lists to `()` argument lists when necessary. For
+instance, the `show` expression above will now be expanded to
+
+ show(x.toString()) .
+
+Scala version 2.0 also relaxes the rules of overriding with respect to
+empty parameter lists. The revised definition of <span>*matching
+members*</span> () makes it now possible to override a method with an
+explicit, but empty parameter list `()` with a parameterless method, and
+<span>*vice versa*</span>. For instance, the following class definition
+is now legal:
+
+ class C {
+ override def toString: String = ...
+ }
+
+Previously this definition would have been rejected, because the
+`toString` method as inherited from `java.lang.Object` takes an empty
+parameter list.
+
+#### Class Parameters
+
+A class parameter may now be prefixed by `val` or `var` ().
+
+#### Private Qualifiers
+
+Previously, Scala had three levels of visibility:
+<span>*private*</span>, <span>*protected*</span> and
+<span>*public*</span>. There was no way to restrict accesses to members
+of the current package, as in Java. Scala 2 now defines access
+qualifiers that let one express this level of visibility, among others.
+In the definition
+
+ private[C] def f(...)
+
+access to `f` is restricted to all code within the class or package `C`
+(which must contain the definition of `f`) ()
+
+#### Changes in the Mixin Model
+
+The model which details mixin composition of classes has changed
+significantly. The main differences are:
+
+1. We now distinguish between <span>*traits*</span> that are used as
+ mixin classes and normal classes. The syntax of traits has been
+ generalized from version 1.0, in that traits are now allowed to have
+ mutable fields. However, as in version 1.0, traits still may not
+ have constructor parameters.
+
+2. Member resolution and super accesses are now both defined in terms
+ of a <span>*class linearization*</span>.
+
+3. Scala’s notion of method overloading has been generalized; in
+ particular, it is now possible to have overloaded variants of the
+ same method in a subclass and in a superclass, or in several
+ different mixins. This makes method overloading in Scala
+ conceptually the same as in Java.
+
+The new mixin model is explained in more detail in .
+
+#### Implicit Parameters
+
+Views in Scala 1.0 have been replaced by the more general concept of
+implicit parameters ()
+
+#### Flexible Typing of Pattern Matching
+
+The new version of Scala implements more flexible typing rules when it
+comes to pattern matching over heterogeneous class hierarchies (). A
+<span>*heterogeneous class hierarchy*</span> is one where subclasses
+inherit a common superclass with different parameter types. With the new
+rules in Scala version 2.0 one can perform pattern matches over such
+hierarchies with more precise typings that keep track of the information
+gained by comparing the types of a selector and a matching pattern ().
+This gives Scala capabilities analogous to guarded algebraic data types.
+
+[^1]: Implemented by Adriaan Moors
diff --git a/spec/README.md b/spec/README.md
index 97c3fdf832..2f582dec5c 100644
--- a/spec/README.md
+++ b/spec/README.md
@@ -8,7 +8,7 @@ Third, we'd like to support different output formats. An html page per chapter w
## Editing
-We use redcarpet 3.1 and jekyll 2 (currently in alpha) to generate the html. Essentially, this is what github pages use.
+We use redcarpet 3.1 and jekyll 2 to generate the html. Essentially, this is what github pages use.
## Building
diff --git a/spec/_includes/numbering.css b/spec/_includes/numbering.css
index 8df08098bc..2a22ce28b5 100644
--- a/spec/_includes/numbering.css
+++ b/spec/_includes/numbering.css
@@ -1,4 +1,3 @@
-// based on http://philarcher.org/css/numberheadings.css,
h1 {
/* must reset here */
counter-reset: chapter {{ page.chapter }};
@@ -40,7 +39,6 @@ h3:before {
display: inline;
margin-right: 1em;
}
-
h3[id*='example'] {
/* must increment here */
counter-increment: example;
diff --git a/spec/_layouts/default.yml b/spec/_layouts/default.yml
index 64ba4a1639..69791d26ad 100644
--- a/spec/_layouts/default.yml
+++ b/spec/_layouts/default.yml
@@ -16,75 +16,31 @@
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/styles/default.min.css">
- <link rel="stylesheet" href="public/octicons/octicons.css">
- <script src="public/highlight/highlight.pack.js"></script>
- <script src="public/scripts/navigation.js"></script>
-
<!-- need to use include to see value of page.chapter variable -->
<style type="text/css">
{% include numbering.css %}
-
- /* proper rendering of MathJax into highlighted code blocks */
- .fixws { white-space: pre; }
- .fixws .math { white-space: nowrap; }
</style>
- <script type="text/javascript">
- // clear content of H3 nodes that start with "Example:"
- // the content is only there to determine ID of the H3 element (redcarpet doesn't let us set css id)
- $( document ).ready(function(){ $("h3[id*='example']").text("") })
-
- // no language auto-detect so that EBDF isn't detected as scala
- hljs.configure({
- languages: []
- });
-
- // syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks
- MathJax.Hub.Queue(function () {
- hljs.initHighlighting();
- $("pre nobr").addClass("fixws");
- })
-
- // and finally TOC generation
- $(document).ready(function() {
- $('.toc').navigation();
- })
- </script>
-
<link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" media="(max-width: 1400px), (orientation: portrait)" href="public/stylesheets/screen-small.css">
<link rel="stylesheet" type="text/css" media="print" href="public/stylesheets/print.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/fonts.css">
<title>{{ page.title }}</title>
</head>
<body>
-<div id="header">
-<a alt="The Scala Language Specification" href="{{site.baseurl}}/"><img id="scala-logo" src="public/images/scala-logo-red-spiral-dark.png" />
-<h1 class="no-numbering">Language Specification</h1></a>
-</div>
-<div id="container">
-<div id="navigation">
-<ol>
- {% assign sorted_pages = site.pages | sort:"name" %}
- {% for post in sorted_pages %}
- {% if post.chapter >= 0 %}
- {% if page.url == post.url %}
- <li class="active-page">
- <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
- <div class="toc"></div>
- </li>
- {% else %}
- <li>
- <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
- </li>
- {% endif %}
- {% endif %}
- {% endfor %}
-</ol>
-</div>
-<div id="content-container">
+ <header>
+ <nav id="chapters"><a id="github" href="https://github.com/scala/scala/tree/2.11.x/spec"><img src="public/images/github-logo@2x.png" alt="Edit at Github"></a>{% assign sorted_pages = site.pages | sort:"name" %}{% for post in sorted_pages %}{% if post.chapter >= 0 %}<a href="{{site.baseurl}}{{ post.url }}">{{post.chapter}} {{ post.title }}</a>{% endif %}{% endfor %}</nav>
+ </header>
+ <aside class="left"><nav id="toc"></nav></aside>
+
+ <main id="content">
{{ content }}
-</div>
-</div>
+ </main>
+
+ <script src="public/scripts/toc.js"></script>
+ <script src="public/scripts/highlight.pack.js"></script>
+ <script src="public/scripts/main.js"></script>
</body>
</html>
diff --git a/spec/_layouts/toc.yml b/spec/_layouts/toc.yml
index caf0be1a3a..4da7d41bea 100644
--- a/spec/_layouts/toc.yml
+++ b/spec/_layouts/toc.yml
@@ -6,23 +6,25 @@
<link rel="icon" type="image/png" href="public/favicon.ico">
<link rel="shortcut icon" type="image/png" href="public/favicon.ico">
- <link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<title>{{ page.title }}</title>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#the-scala-language-specification').css('display','none');
- })
- </script>
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/screen-toc.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/fonts.css">
</head>
<body>
-<div id="header">
-<a alt="The Scala Language Specification" href="{{site.baseurl}}/"><img id="scala-logo" src="public/images/scala-logo-red-spiral-dark.png" />
-<h1 class="no-numbering">Language Specification</h1></a>
-</div>
+<header>
+ <div id="header-main">
+ <img id="scala-logo" src="public/images/scala-spiral-white.png" />
+ <span id="title">Scala Language Specification</span>
+ <a id="github" href="https://github.com/scala/scala/tree/2.11.x/spec"><img src="public/images/github-logo@2x.png" alt="Edit at Github"></a>
+ </div>
+ <div id="header-sub">Version 2.11</div>
+</header>
+<main>
{{ content }}
-
+</main>
</body>
</html>
diff --git a/spec/index.md b/spec/index.md
index ee9c2a5f78..d7e79dafb7 100644
--- a/spec/index.md
+++ b/spec/index.md
@@ -1,18 +1,9 @@
---
-title: Scala Language Reference
+title: Scala Language Specification
layout: toc
---
-# The Scala Language Specification
-# Version 2.11
-
-### Maintained online at [https://github.com/scala/scala/tree/2.11.x/spec](https://github.com/scala/scala/tree/2.11.x/spec)
-
-### Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors, Lukas Rytz, Michel Schinz, Erik Stenman, Matthias Zenger
-
-### Markdown Conversion by Iain McGinniss.
-
-## Table of Contents
+# Table of Contents
<ol>
{% assign sorted_pages = site.pages | sort:"name" %}
@@ -27,7 +18,13 @@ layout: toc
{% endfor %}
</ol>
-## Preface
+#### Authors and Contributors
+
+Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors, Lukas Rytz, Michel Schinz, Erik Stenman, Matthias Zenger
+
+Markdown Conversion by Iain McGinniss.
+
+#### Preface
Scala is a Java-like programming language which unifies
object-oriented and functional programming. It is a pure
diff --git a/spec/public/fonts/Heuristica-Bold.woff b/spec/public/fonts/Heuristica-Bold.woff
new file mode 100644
index 0000000000..904579683d
--- /dev/null
+++ b/spec/public/fonts/Heuristica-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-BoldItalic.woff b/spec/public/fonts/Heuristica-BoldItalic.woff
new file mode 100644
index 0000000000..a3c5234453
--- /dev/null
+++ b/spec/public/fonts/Heuristica-BoldItalic.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-Regular.woff b/spec/public/fonts/Heuristica-Regular.woff
new file mode 100644
index 0000000000..f5c1f8b2db
--- /dev/null
+++ b/spec/public/fonts/Heuristica-Regular.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-RegularItalic.woff b/spec/public/fonts/Heuristica-RegularItalic.woff
new file mode 100644
index 0000000000..d2c8664593
--- /dev/null
+++ b/spec/public/fonts/Heuristica-RegularItalic.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-Bold.woff b/spec/public/fonts/LuxiMono-Bold.woff
new file mode 100644
index 0000000000..8581bb5aa4
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-BoldOblique.woff b/spec/public/fonts/LuxiMono-BoldOblique.woff
new file mode 100644
index 0000000000..607ccf5cd0
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-BoldOblique.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-Regular.woff b/spec/public/fonts/LuxiMono-Regular.woff
new file mode 100644
index 0000000000..a478ad9ef2
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-Regular.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-RegularOblique.woff b/spec/public/fonts/LuxiMono-RegularOblique.woff
new file mode 100644
index 0000000000..26999f990f
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-RegularOblique.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiSans-Bold.woff b/spec/public/fonts/LuxiSans-Bold.woff
new file mode 100644
index 0000000000..162621568b
--- /dev/null
+++ b/spec/public/fonts/LuxiSans-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiSans-Regular.woff b/spec/public/fonts/LuxiSans-Regular.woff
new file mode 100644
index 0000000000..89d980218f
--- /dev/null
+++ b/spec/public/fonts/LuxiSans-Regular.woff
Binary files differ
diff --git a/spec/public/images/github-logo@2x.png b/spec/public/images/github-logo@2x.png
new file mode 100644
index 0000000000..285b0fee2f
--- /dev/null
+++ b/spec/public/images/github-logo@2x.png
Binary files differ
diff --git a/spec/public/images/scala-logo-red-spiral-dark.png b/spec/public/images/scala-logo-red-spiral-dark.png
deleted file mode 100644
index 09b66b5e6a..0000000000
--- a/spec/public/images/scala-logo-red-spiral-dark.png
+++ /dev/null
Binary files differ
diff --git a/spec/public/images/scala-spiral-white.png b/spec/public/images/scala-spiral-white.png
new file mode 100644
index 0000000000..46aaf80824
--- /dev/null
+++ b/spec/public/images/scala-spiral-white.png
Binary files differ
diff --git a/spec/public/highlight/LICENSE b/spec/public/scripts/LICENSE-highlight
index 422deb7350..fe2f67b162 100644
--- a/spec/public/highlight/LICENSE
+++ b/spec/public/scripts/LICENSE-highlight
@@ -8,8 +8,8 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- * Neither the name of highlight.js nor the names of its contributors
- may be used to endorse or promote products derived from this software
+ * Neither the name of highlight.js nor the names of its contributors
+ may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
diff --git a/spec/public/scripts/LICENSE-toc b/spec/public/scripts/LICENSE-toc
new file mode 100644
index 0000000000..4e236e8696
--- /dev/null
+++ b/spec/public/scripts/LICENSE-toc
@@ -0,0 +1,18 @@
+(The MIT License)
+Copyright (c) 2013 Greg Allen
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/spec/public/highlight/highlight.pack.js b/spec/public/scripts/highlight.pack.js
index bfeca09abb..bfeca09abb 100644
--- a/spec/public/highlight/highlight.pack.js
+++ b/spec/public/scripts/highlight.pack.js
diff --git a/spec/public/scripts/main.js b/spec/public/scripts/main.js
new file mode 100644
index 0000000000..f0509aba41
--- /dev/null
+++ b/spec/public/scripts/main.js
@@ -0,0 +1,57 @@
+function currentChapter() {
+ var path = document.location.pathname;
+ var idx = path.lastIndexOf("/") + 1;
+ var chap = path.substring(idx, idx + 2);
+ return parseInt(chap, 10);
+}
+
+function heading(i, heading, $heading) {
+ var currentLevel = parseInt(heading.tagName.substring(1));
+ var result = "";
+ if (currentLevel === this.headerLevel) {
+ this.headerCounts[this.headerLevel] += 1;
+ return "" + this.headerCounts[this.headerLevel] + " " + $heading.text();
+ } else if (currentLevel < this.headerLevel) {
+ while(currentLevel < this.headerLevel) {
+ this.headerCounts[this.headerLevel] = 1;
+ this.headerLevel -= 1;
+ }
+ this.headerCounts[this.headerLevel] += 1;
+ return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
+ } else {
+ while(currentLevel > this.headerLevel) {
+ this.headerLevel += 1;
+ this.headerCounts[this.headerLevel] = 1;
+ }
+ return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
+ }
+}
+
+$('#toc').toc(
+ {
+ 'selectors': 'h1,h2,h3',
+ 'smoothScrolling': false,
+ 'chapter': currentChapter(),
+ 'headerLevel': 1,
+ 'headerCounts': [-1, currentChapter() - 1, 1, 1],
+ 'headerText': heading
+ }
+);
+
+// no language auto-detect so that EBNF isn't detected as scala
+hljs.configure({
+ languages: []
+});
+
+// syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks
+MathJax.Hub.Queue(function () {
+ hljs.initHighlighting();
+ $("pre nobr").addClass("fixws");
+})
+
+$("#chapters a").each(function (index) {
+ if (document.location.pathname.endsWith($(this).attr("href")))
+ $(this).addClass("chapter-active");
+ else
+ $(this).removeClass("chapter-active");
+});
diff --git a/spec/public/scripts/navigation.js b/spec/public/scripts/navigation.js
deleted file mode 100644
index c046bf4d54..0000000000
--- a/spec/public/scripts/navigation.js
+++ /dev/null
@@ -1,70 +0,0 @@
-(function($){ $.fn.navigation = function() {
-
- // the TOC already contains H1 so we start at H2
- var headers = $('h2, h3, h4, h5').filter(function() {
- // exclude examples
- if (this.id.substr(0, 7) == 'example') {
- return false;
- }
-
- // get all headers with an id
- return this.id;
- });
-
- var output = $(this);
-
- var get_level = function(n) { return parseInt(n.nodeName.replace('H', ''), 10); }
-
- var back_to_top = '<span title="Return to top" class="to_top octicon octicon-chevron-up"></span>';
-
- if (headers.length && output.length) {
- var level = get_level(headers[0]);
- var current_level;
- var html = '<ol>';
-
- headers.each(function(_, header) {
- current_level = get_level(header);
-
- if (current_level === level) {
- // same level as before
- html += '<li><a href="#' + header.id + '">' + header.innerHTML + '</a>';
- } else if (current_level <= level) {
- // higher level, we go back up and chose intermediary lists
- for(i = current_level; i < level; i++) {
- html += '</li></ol>';
- }
- html += '<li><a href="#' + header.id + '">' + header.innerHTML + '</a>';
- } else if (current_level > level) {
- // lower level, we open new nested lists
- for(i = current_level; i > level; i--) {
- html += '<ol><li>';
- }
- html += '<a href="#' + header.id + '">' + header.innerHTML + '</a>';
- }
-
- var header_link = '<a class="anchor" href="#' + header.id + '"><span class="octicon octicon-link"></span></a>';
- $(header).prepend(header_link);
-
- if (!$(header).prev().is('h1')) {
- $(header).after(back_to_top);
- }
-
- level = current_level;
- });
-
- html += '</ol>';
-
- output.html(html);
- }
-
- // back to top links
- $(document).on('click', '.to_top', function() {
- $(window).scrollTop(0);
- window.location.hash = '';
- });
-
- // we add one more at the end of the document
- $('#content-container').append(back_to_top);
-
-};})(jQuery);
-
diff --git a/spec/public/scripts/toc.js b/spec/public/scripts/toc.js
new file mode 100644
index 0000000000..070d7b7a93
--- /dev/null
+++ b/spec/public/scripts/toc.js
@@ -0,0 +1,128 @@
+/*!
+ * toc - jQuery Table of Contents Plugin
+ * v0.3.2
+ * http://projects.jga.me/toc/
+ * copyright Greg Allen 2014
+ * MIT License
+*/
+(function($) {
+var verboseIdCache = {};
+$.fn.toc = function(options) {
+ var self = this;
+ var opts = $.extend({}, jQuery.fn.toc.defaults, options);
+
+ var container = $(opts.container);
+ var headings = $(opts.selectors, container);
+ var headingOffsets = [];
+ var activeClassName = opts.activeClass;
+
+ var scrollTo = function(e, callback) {
+ $('li', self).removeClass(activeClassName);
+ $(e.target).parent().addClass(activeClassName);
+ };
+
+ //highlight on scroll
+ var timeout;
+ var highlightOnScroll = function(e) {
+ if (timeout) {
+ clearTimeout(timeout);
+ }
+ timeout = setTimeout(function() {
+ var top = $(window).scrollTop(),
+ highlighted, closest = Number.MAX_VALUE, index = 0;
+
+ for (var i = 0, c = headingOffsets.length; i < c; i++) {
+ var currentClosest = Math.abs(headingOffsets[i] - top);
+ if (currentClosest < closest) {
+ index = i;
+ closest = currentClosest;
+ }
+ }
+
+ $('li', self).removeClass(activeClassName);
+ highlighted = $('li:eq('+ index +')', self).addClass(activeClassName);
+ opts.onHighlight(highlighted);
+ }, 50);
+ };
+ if (opts.highlightOnScroll) {
+ $(window).bind('scroll', highlightOnScroll);
+ highlightOnScroll();
+ }
+
+ return this.each(function() {
+ //build TOC
+ var el = $(this);
+ var ul = $(opts.listType);
+
+ headings.each(function(i, heading) {
+ var $h = $(heading);
+ headingOffsets.push($h.offset().top - opts.highlightOffset);
+
+ var anchorName = opts.anchorName(i, heading, opts.prefix);
+
+ //add anchor
+ if(heading.id !== anchorName) {
+ var anchor = $('<span/>').attr('id', anchorName).insertBefore($h);
+ }
+
+ //build TOC item
+ var a = $('<a/>')
+ .text(opts.headerText(i, heading, $h))
+ .attr('href', '#' + anchorName)
+ .bind('click', function(e) {
+ $(window).unbind('scroll', highlightOnScroll);
+ scrollTo(e, function() {
+ $(window).bind('scroll', highlightOnScroll);
+ });
+ el.trigger('selected', $(this).attr('href'));
+ });
+
+ var li = $('<li/>')
+ .addClass(opts.itemClass(i, heading, $h, opts.prefix))
+ .append(a);
+
+ ul.append(li);
+ });
+ el.html(ul);
+ });
+};
+
+
+jQuery.fn.toc.defaults = {
+ container: 'body',
+ listType: '<ul/>',
+ selectors: 'h1,h2,h3',
+ prefix: 'toc',
+ activeClass: 'toc-active',
+ onHighlight: function() {},
+ highlightOnScroll: true,
+ highlightOffset: 100,
+ anchorName: function(i, heading, prefix) {
+ if(heading.id.length) {
+ return heading.id;
+ }
+
+ var candidateId = $(heading).text().replace(/[^a-z0-9]/ig, ' ').replace(/\s+/g, '-').toLowerCase();
+ if (verboseIdCache[candidateId]) {
+ var j = 2;
+
+ while(verboseIdCache[candidateId + j]) {
+ j++;
+ }
+ candidateId = candidateId + '-' + j;
+
+ }
+ verboseIdCache[candidateId] = true;
+
+ return prefix + '-' + candidateId;
+ },
+ headerText: function(i, heading, $heading) {
+ return $heading.text();
+ },
+ itemClass: function(i, heading, $heading, prefix) {
+ return prefix + '-' + $heading[0].tagName.toLowerCase();
+ }
+
+};
+
+})(jQuery);
diff --git a/spec/public/stylesheets/fonts.css b/spec/public/stylesheets/fonts.css
new file mode 100644
index 0000000000..36efb2bbd5
--- /dev/null
+++ b/spec/public/stylesheets/fonts.css
@@ -0,0 +1,73 @@
+@font-face {
+ font-family: 'Luxi Sans';
+ src: local('Luxi Sans Regular'),
+ url('../fonts/LuxiSans-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Luxi Sans';
+ src: local('Luxi Sans Bold'),
+ url('../fonts/LuxiSans-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Regular'),
+ url('../fonts/LuxiMono-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Oblique'),
+ url('../fonts/LuxiMono-BoldOblique.woff') format('woff');
+ font-weight: normal;
+ font-style: oblique;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Bold'),
+ url('../fonts/LuxiMono-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Bold Oblique'),
+ url('../fonts/LuxiMono-BoldOblique.woff') format('woff');
+ font-weight: bold;
+ font-style: oblique;
+}
+
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Regular'),
+ url('../fonts/Heuristica-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Italic'),
+ url('../fonts/Heuristica-RegularItalic.woff') format('woff');
+ font-weight: normal;
+ font-style: italic;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Bold'),
+ url('../fonts/Heuristica-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Bold Italic'),
+ url('../fonts/Heuristica-BoldItalic.woff') format('woff');
+ font-weight: bold;
+ font-style: italic;
+}
diff --git a/spec/public/stylesheets/screen-small.css b/spec/public/stylesheets/screen-small.css
new file mode 100644
index 0000000000..674db7c490
--- /dev/null
+++ b/spec/public/stylesheets/screen-small.css
@@ -0,0 +1,57 @@
+body {
+ padding: 0px;
+ margin: 0px;
+}
+aside.left {
+ position: relative;
+ margin: 0px auto;
+ overflow: visible;
+ height: inherit;
+ margin-bottom: 40px;
+ background-color: #073642;
+}
+header {
+ position: relative;
+ height: inherit;
+ min-height: 32px;
+}
+main {
+ max-width: 1000px;
+ min-width: 600px;
+ margin: 0 auto;
+}
+
+#chapters a {
+ font-size: 14px;
+ max-height: 32px;
+ padding: 4px 8px;
+ white-space: nowrap;
+ display: inline-block;
+}
+#chapters > #github {
+ padding: 14px;
+}
+
+#toc {
+ overflow: visible;
+}
+#toc .toc-active {
+ background: inherit;
+}
+#toc .toc-h1 {
+ display: inherit;
+}
+#toc .toc-h1 a {
+ padding-left: 10px;
+ color: #FFFFFF;
+ background: #72D0EB;
+}
+#toc .toc-h2 a {
+ padding-left: 30px;
+}
+#toc .toc-h3 a {
+ padding-left: 50px;
+}
+#toc a {
+ font-size: 14px;
+}
diff --git a/spec/public/stylesheets/screen-toc.css b/spec/public/stylesheets/screen-toc.css
new file mode 100644
index 0000000000..7a04bd00f9
--- /dev/null
+++ b/spec/public/stylesheets/screen-toc.css
@@ -0,0 +1,37 @@
+body {
+ padding: 0px;
+ margin: 0px;
+}
+header {
+ height: 96px;
+ padding: 0px;
+ width: 100%;
+ position: relative;
+ color: #FFFFFF;
+}
+#header-main {
+ height: 68px;
+ line-height: 1.2;
+ font-size: 32px;
+}
+#header-sub {
+ padding-left: 64px;
+ height: 28px;
+ background-color:#72D0EB;
+ vertical-align: middle;
+}
+#scala-logo {
+ padding: 10px;
+}
+#title {
+ vertical-align: middle;
+}
+#github {
+ height: 40px;
+ padding: 14px;
+ float: right;
+ font-size: 0px;
+}
+li {
+ margin: 5px;
+}
diff --git a/spec/public/stylesheets/screen.css b/spec/public/stylesheets/screen.css
index dbb3ebe1b3..fdddba0b45 100644
--- a/spec/public/stylesheets/screen.css
+++ b/spec/public/stylesheets/screen.css
@@ -1,8 +1,8 @@
/* from https://gist.github.com/andyferra/2554919 */
body {
- font-family: Helvetica, arial, sans-serif;
- font-size: 14px;
+ font-family:Heuristica,Georgia,serif;
+ color: #222222;
line-height: 1.6;
padding-bottom: 10px;
@@ -18,7 +18,11 @@ body {
}
a {
- color: #4183C4;
+ color: #08C;
+ text-decoration: none;
+}
+a:hover, a:focus {
+
}
a.absent {
color: #cc0000;
@@ -41,13 +45,21 @@ a.anchor span {
}
h1, h2, h3, h4, h5, h6 {
- margin: 20px 0 10px;
+ margin: 30px 0 0px;
+ padding: 0;
+ /* Fix anchor position due to header */
+ padding-top: 32px;
+ margin-top: -32px;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative;
}
+h1, h2 {
+ font-weight: normal;
+}
+
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
text-decoration: none;
}
@@ -95,7 +107,6 @@ h1 {
h2 {
font-size: 24px;
- border-bottom: 1px solid #cccccc;
color: black;
}
@@ -117,7 +128,7 @@ h6 {
}
p, blockquote, ul, ol, dl, li, table, pre {
- margin: 15px 0;
+ margin: 5px 0 15px;
-moz-font-feature-settings: "onum";
-ms-font-feature-settings: "onum";
-webkit-font-feature-settings: "onum";
@@ -125,7 +136,7 @@ p, blockquote, ul, ol, dl, li, table, pre {
}
hr {
- background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0;
+ background: transparent repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
@@ -207,7 +218,7 @@ dl dd > :last-child {
blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
- color: #777777;
+ color: #222222;
}
blockquote > :first-child {
margin-top: 0;
@@ -215,31 +226,34 @@ blockquote > :first-child {
blockquote > :last-child {
margin-bottom: 0;
}
+blockquote:before {
+ content: "Example";
+ color: #777777;
+ font-size: 14px;
+ font-weight: bold;
+}
table {
padding: 0;
+ margin: 0;
+ border: none;
+ border-collapse: collapse;
}
table tr {
- border-top: 1px solid #cccccc;
background-color: white;
- margin: 0;
- padding: 0;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
table tr th {
+ background-color: #EAEAEA;
font-weight: bold;
- border: 1px solid #cccccc;
text-align: left;
- margin: 0;
- padding: 6px 13px;
+ padding: 5px 13px;
}
table tr td {
- border: 1px solid #cccccc;
text-align: left;
- margin: 0;
- padding: 6px 13px;
+ padding: 5px 13px;
}
table tr th :first-child, table tr td :first-child {
margin-top: 0;
@@ -327,11 +341,14 @@ span.float-right > span {
text-align: right;
}
+pre, code, tt {
+ font:14px "Luxi Mono", 'andale mono', 'lucida console', monospace;
+ line-height:1.5;
+}
+
.highlight pre {
- border: 1px solid #eaeaea;
- background-color: #f8f8f8;
+ background-color: #F8F8F8;
border-radius: 3px;
- line-height: 19px;
overflow: auto;
padding: 6px 10px;
white-space: nowrap;
@@ -343,86 +360,144 @@ code {
margin: 0;
padding: 0;
white-space: pre;
- font-size: 16px;
}
-#navigation {
- margin-right: 10px;
- float: right;
- width: 26%;
- display: inline;
- color: #8B8B8B;
- font-size: 15px;
- font-weight: bold;
- background-color: #F3F4F4;
+aside.left {
+ height: 100%;
+ position: fixed;
+ direction: rtl;
+ overflow: auto;
+ left: 0px;
+ width: 320px;
+ bottom: -32px;
+ font-family: "Luxi Sans", serif;
+ background-color: #073642;
}
-#content-container {
- float: left;
- width: 70%;
- display: inline;
+aside.left > nav {
+ direction: ltr;
+ top: 32px;
+ padding-bottom: 32px;
}
-#container {
- padding-top: 10px;
- width: 100%;
+article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
+ display: block;
}
-#navigation a {
- text-decoration: none;
- color: #8B8B8B;
+audio, canvas, img, svg, video {
+ vertical-align: middle;
}
-#navigation a:hover {
- text-decoration: underline;
+audio, canvas, progress, video {
+ display: inline-block;
+ vertical-align: baseline;
}
-.active-page {
- color: #171717;
+main {
+ position: relative;
+ top: 32px;
+ margin: 0 0 0 320px;
+ padding: 0px 32px;
+ max-width: 800px;
+ min-width: 800px;
+ min-height: 580px;
+ background-color: #FFF;
}
-.active-page a {
- color: #171717 !important;
+header {
+ position: fixed;
+ top: 0px;
+ left: 0px;
+ height: 32px;
+ width: 100%;
+ background-color: #002B36;
+ margin: 0px 0px;
+ padding: 0px 0px;
+ font-family: "Luxi Sans", serif;
+ font-weight: bold;
+ z-index: 10;
+ overflow: hidden;
+ text-shadow: 1px 1px 0px rgba(0, 43, 54, 0.15);
}
-.to_top {
- position: absolute;
- margin-top: -35px;
- right: 27%;
- color: gray;
- cursor: pointer;
- width: 16px; height: 16px;
- display: block;
+#chapters a {
+ color: #FFFFFF;
+ text-decoration: none;
+ font-size: 0.63vw;
+ padding: 100% 8px;
}
-.to_top:hover {
- color: black;
+#chapters a:hover, #chapters a:focus, #github:hover, #github:focus {
+ background: #DC322F;
+ -webkit-transition: background .2s ease-in;
+ -moz-transition: background .2s ease-in;
+ -ms-transition: background .2s ease-in;
+ -o-transition: background .2s ease-in;
+ transition: background .2s ease-in;
}
-#scala-logo {
- float: left;
- width: 168px;
- height: 48px;
- margin-right: 25px;
+#chapters a.chapter-active {
+ background: #72D0EB;
}
-#header {
- padding-top: 16px;
- padding-bottom: 10px;
- margin-bottom: 10px;
- height: 64px;
- border-bottom: 1px solid #cccccc;
+
+#toc ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
}
-#header a {
- height: 100%;
- display: block;
+#toc li {
+ margin: 0;
+ padding: 0;
+}
+
+#toc a {
+ color: #FFFFFF; /*#073642;*/
+ font-weight: bold;
+ font-size: 12px;
+ display: block;
+ text-shadow: 1px 1px 0px rgba(0, 43, 54, 0.15);
+}
+
+#toc a:hover, #toc a:focus {
+ background: #DC322F;
text-decoration: none;
+ -webkit-transition: background .2s ease-in;
+ -moz-transition: background .2s ease-in;
+ -ms-transition: background .2s ease-in;
+ -o-transition: background .2s ease-in;
+ transition: background .2s ease-in;
}
-#header h1 {
- cursor: pointer;
- padding-top: 6px;
- margin-bottom: 0px;
- font-size: 30px;
+#toc .toc-h1 {
+ display: none;
+}
+
+#toc .toc-h2 a {
+ padding-left: 10px;
+}
+
+#toc .toc-h3 a {
+ padding-left: 30px;
+}
+
+#toc .toc-active {
+ background: #72D0EB;
+}
+
+#toc .toc-active a {
+ color: #FFFFFF;
+}
+
+#chapters > #github {
+ padding: 0px;
+ float: right;
+}
+
+.hljs{
+ background: #f8f8f8;
}
+/* proper rendering of MathJax into highlighted code blocks */
+.fixws { white-space: pre; }
+.fixws .math { white-space: nowrap; }