summaryrefslogtreecommitdiff
path: root/spec/08-pattern-matching.md
diff options
context:
space:
mode:
authorDaniel Barclay <dbarclay@savi.com>2016-08-21 12:38:04 -0400
committerDaniel Barclay <dbarclay@savi.com>2016-08-21 12:38:04 -0400
commit34bbd14189b70d2757bb8e973f6a768f9b3b3459 (patch)
treeb4e5ad0813f440e7577fe239c90f04d967946b65 /spec/08-pattern-matching.md
parentebc7f8ffb0927e79da8e6ecbbd8dca2e0d2e56a0 (diff)
downloadscala-34bbd14189b70d2757bb8e973f6a768f9b3b3459.tar.gz
scala-34bbd14189b70d2757bb8e973f6a768f9b3b3459.tar.bz2
scala-34bbd14189b70d2757bb8e973f6a768f9b3b3459.zip
Editorial: Italicized more defining occurrences of terms.
Diffstat (limited to 'spec/08-pattern-matching.md')
-rw-r--r--spec/08-pattern-matching.md24
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/08-pattern-matching.md b/spec/08-pattern-matching.md
index d496388a91..d2a84b09db 100644
--- a/spec/08-pattern-matching.md
+++ b/spec/08-pattern-matching.md
@@ -60,7 +60,7 @@ patterns.
| varid
```
-A variable pattern $x$ is a simple identifier which starts with a
+A _variable pattern_ $x$ is a simple identifier which starts with a
lower case letter. It matches any value, and binds the variable name
to that value. The type of $x$ is the expected type of the pattern as
given from outside. A special case is the wild-card pattern `_`
@@ -73,7 +73,7 @@ which is treated as if it was a fresh variable on each occurrence.
| `_' `:' TypePat
```
-A typed pattern $x: T$ consists of a pattern variable $x$ and a
+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
each type variable and wildcard is replaced by a fresh, unknown type.
This pattern matches any value matched by the [type pattern](#type-patterns)
@@ -86,7 +86,7 @@ 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$,
@@ -98,7 +98,7 @@ and it binds the variable name to that value.
SimplePattern ::= Literal
```
-A literal pattern $L$ matches any value that is equal (in terms of
+A _literal pattern_ $L$ matches any value that is equal (in terms of
`==`) to the literal $L$. The type of $L$ must conform to the
expected type of the pattern.
@@ -108,7 +108,7 @@ expected type of the pattern.
SimplePattern ::= StableId
```
-A stable identifier pattern is a [stable identifier](03-types.html#paths) $r$.
+A _stable identifier pattern_ is a [stable identifier](03-types.html#paths) $r$.
The type of $r$ must conform to the expected
type of the pattern. The pattern matches any value $v$ such that
`$r$ == $v$` (see [here](12-the-scala-standard-library.html#root-classes)).
@@ -147,7 +147,7 @@ argument of `f` are equal.
SimplePattern ::= StableId `(' [Patterns] `)
```
-A constructor pattern is of the form $c(p_1 , \ldots , p_n)$ where $n
+A _constructor pattern_ is of the form $c(p_1 , \ldots , p_n)$ where $n
\geq 0$. It consists of a stable identifier $c$, followed by element
patterns $p_1 , \ldots , p_n$. The constructor $c$ is a simple or
qualified name which denotes a [case class](05-classes-and-objects.html#case-classes).
@@ -173,7 +173,7 @@ repeated parameter. This is further discussed [here](#pattern-sequences).
SimplePattern ::= `(' [Patterns] `)'
```
-A tuple pattern `($p_1 , \ldots , p_n$)` is an alias
+A _tuple pattern_ `($p_1 , \ldots , p_n$)` is an alias
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`.
@@ -184,7 +184,7 @@ where $n \geq 2$. The empty tuple
SimplePattern ::= StableId `(' [Patterns] `)'
```
-An extractor pattern $x(p_1 , \ldots , p_n)$ where $n \geq 0$ is of
+An _extractor pattern_ $x(p_1 , \ldots , p_n)$ where $n \geq 0$ is of
the same syntactic form as a constructor pattern. However, instead of
a case class, the stable identifier $x$ denotes an object which has a
member method named `unapply` or `unapplySeq` that matches
@@ -244,7 +244,7 @@ val y = x match {
SimplePattern ::= StableId `(' [Patterns `,'] [varid `@'] `_' `*' `)'
```
-A pattern sequence $p_1 , \ldots , p_n$ appears in two contexts.
+A _pattern sequence_ $p_1 , \ldots , p_n$ appears in two contexts.
First, in a constructor pattern $c(q_1 , \ldots , q_m, p_1 , \ldots , p_n)$, where $c$ is a case class which has $m+1$ primary constructor parameters, ending in a [repeated parameter](04-basic-declarations-and-definitions.html#repeated-parameters) of type `S*`.
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$.
@@ -265,7 +265,7 @@ p_n$.
Pattern3 ::= SimplePattern {id [nl] SimplePattern}
```
-An infix operation pattern $p;\mathit{op};q$ is a shorthand for the
+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
[expressions](06-expressions.html#prefix,-infix,-and-postfix-operations).
@@ -280,7 +280,7 @@ shorthand for the constructor or extractor pattern $\mathit{op}(p, q_1
Pattern ::= Pattern1 { `|' Pattern1 }
```
-A pattern alternative `$p_1$ | $\ldots$ | $p_n$`
+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 not bind variables other than wildcards. The alternative pattern
@@ -524,7 +524,7 @@ function's declared result type, `Number`.
CaseClause ::= `case' Pattern [Guard] `=>' Block
```
-A pattern matching expression
+A _pattern matching expression_
```scala
e match { case $p_1$ => $b_1$ $\ldots$ case $p_n$ => $b_n$ }