summaryrefslogtreecommitdiff
path: root/05-types.md
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-26 20:35:25 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-26 20:42:50 -0700
commitabd0895322985dd4a590f3dd96a488f4e4ff87bf (patch)
tree458be2ba2e8e9c017ff51b7e50a402b688179b4a /05-types.md
parent5997e32397db4efac1cbb3b74bd29289d203a775 (diff)
downloadscala-abd0895322985dd4a590f3dd96a488f4e4ff87bf.tar.gz
scala-abd0895322985dd4a590f3dd96a488f4e4ff87bf.tar.bz2
scala-abd0895322985dd4a590f3dd96a488f4e4ff87bf.zip
Fix #6: automatic section numbering.
Add chapter number to YAML, which is replace in numbering.css. Use CSS counters for chapters, sections, subsections | examples. Examples are detected by looking at the H3 element's id, which redcarpet derives from the heading's title. It must start with "Example:", and the whole title is suppressed by a little javascript, so we can make Examples look like in the pdf. For example, `### Example:` becomes `Example 3.2.10`, if it's the 10th example in Section 3.2.
Diffstat (limited to '05-types.md')
-rw-r--r--05-types.md21
1 files changed, 11 insertions, 10 deletions
diff --git a/05-types.md b/05-types.md
index b54e9b983b..c2996ddb4b 100644
--- a/05-types.md
+++ b/05-types.md
@@ -1,6 +1,7 @@
---
title: Types
layout: default
+chapter: 3
---
# Types
@@ -148,7 +149,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: fully qualified type designators
+### Example:
Some type designators and their expansions are listed below. We assume
a local type parameter $t$, a value `maintable`
@@ -181,7 +182,7 @@ 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:
Given the partial type definitions:
```
@@ -205,7 +206,7 @@ F[List, Int]
G[S, String]
```
-###### Example: ill-formed types
+### Example:
Given the [above type definitions](example-parameterized-types),
the following types are ill-formed:
@@ -261,7 +262,7 @@ An annotated type $T$ `$a_1 , \ldots , a_n$`
attaches [annotations](13-user-defined-annotations.html#user-defined-annotations)
$a_1 , \ldots , a_n$ to the type $T$.
-###### Example: annotated type
+### Example:
The following type adds the `@suspendable` annotation to the type `String`:
@@ -309,7 +310,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: structural refinement in a method's parameter type
+### Example:
The following example shows how to declare and use a method which
a parameter type that contains a refinement with structural declarations.
@@ -509,7 +510,7 @@ or [tuple types](#tuple-types).
Their expansion is then the expansion in the equivalent parameterized
type.
-###### Example: existential types
+### Example:
Assume the class definitions
@@ -533,7 +534,7 @@ An alternative formulation of the first type above using wildcard syntax is:
Ref[_ <: java.lang.Number]
```
-###### Example: abbreviating an existential type with the underscore
+### Example:
The type `List[List[_]]` is equivalent to the existential type
@@ -541,7 +542,7 @@ The type `List[List[_]]` is equivalent to the existential type
List[List[t] forSome { type t }] .
```
-###### Example: existential type equivalence
+### Example:
Assume a covariant type
@@ -670,7 +671,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: The definitions
+### Example:
```
def println: Unit
def println(s: String): Unit = $\ldots$
@@ -688,7 +689,7 @@ println: => Unit $\overload$
[A] (A) (A => String) Unit
```
-###### Example: The definitions
+### Example:
```
def f(x: T): T = $\ldots$
val f = 0