summaryrefslogtreecommitdiff
path: root/07-classes-and-objects.md
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 15:27:16 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 15:46:38 -0700
commit32e0943c02a3bdf9e57e87b6e0c0ee55da9194e2 (patch)
tree42142ea1d7884eb6ce7b9cbc6b12952cf4fa9c40 /07-classes-and-objects.md
parent64b733819d95b2ee20942faf2cfbee670b1c11c0 (diff)
downloadscala-32e0943c02a3bdf9e57e87b6e0c0ee55da9194e2.tar.gz
scala-32e0943c02a3bdf9e57e87b6e0c0ee55da9194e2.tar.bz2
scala-32e0943c02a3bdf9e57e87b6e0c0ee55da9194e2.zip
SI-5065 val/var is optional for a constructor parameter
Diffstat (limited to '07-classes-and-objects.md')
-rw-r--r--07-classes-and-objects.md41
1 files changed, 18 insertions, 23 deletions
diff --git a/07-classes-and-objects.md b/07-classes-and-objects.md
index 46581df80b..617de328b2 100644
--- a/07-classes-and-objects.md
+++ b/07-classes-and-objects.md
@@ -673,7 +673,7 @@ ClassParamClauses ::= {ClassParamClause}
[[nl] `(' implicit ClassParams `)']
ClassParamClause ::= [nl] `(' [ClassParams] ')'
ClassParams ::= ClassParam {`,' ClassParam}
-ClassParam ::= {Annotation} [{Modifier} (`val' | `var')]
+ClassParam ::= {Annotation} {Modifier} [(`val' | `var')]
id [`:' ParamType] [`=' Expr]
ClassTemplateOpt ::= `extends' ClassTemplate | [[`extends'] TemplateBody]
```
@@ -699,33 +699,28 @@ Here,
If any annotations are given, they apply to the primary constructor of the
class.
- $m$ is an [access modifier](#modifiers) such as
- `private` or `protected`, possibly with a qualification. If
- such an access modifier is given it applies to the primary constructor
- to the class.
+ `private` or `protected`, possibly with a qualification.
+ If such an access modifier is given it applies to the primary constructor of the class.
- $(\mathit{ps}_1)\ldots(\mathit{ps}_n)$ are formal value parameter clauses for
- the _primary
- constructor_ of the class. The scope of a formal value parameter includes
+ the _primary constructor_ of the class. The scope of a formal value parameter includes
all subsequent parameter sections and the template $t$. However, a formal
- value parameter may not form
- part of the types of any of the parent classes or members of the class
- template $t$.
+ value parameter may not form part of the types of any of the parent classes or members of the class template $t$.
It is illegal to define two formal value parameters with the same name.
- If no formal parameter sections are given,
- an empty parameter section `()` is assumed.
+
+ If no formal parameter sections are given, an empty parameter section `()` is assumed.
If a formal parameter declaration $x: T$ is preceded by a `val`
- or `var` keyword, an accessor (getter)
- [definition](#variable-declarations-and-definitions)
- for this parameter is implicitly added to the
- class. The getter introduces a value member $x$ of class $c$ that is
- defined as an alias of the parameter. If the introducing keyword is
- `var`, a setter accessor [`$x$_=`](#variable-declarations-and-definitions)
- is also implicitly added to the class. In invocation of that setter
- `$x$_=($e$)` changes the value of the parameter to the result of evaluating
- $e$. The formal parameter declaration may contain modifiers, which then
- carry over to the accessor definition(s). A formal parameter prefixed
- by `val` or `var` may not at the same time be a
- [call-by-name parameter](#by-name-parameters).
+ or `var` keyword, an accessor (getter) [definition](#variable-declarations-and-definitions)
+ for this parameter is implicitly added to the class.
+
+ The getter introduces a value member $x$ of class $c$ that is defined as an alias of the parameter.
+ If the introducing keyword is `var`, a setter accessor [`$x$_=`](#variable-declarations-and-definitions) is also implicitly added to the class.
+ In invocation of that setter `$x$_=($e$)` changes the value of the parameter to the result of evaluating $e$.
+
+ The formal parameter declaration may contain modifiers, which then carry over to the accessor definition(s).
+ When access modifiers are given for a parameter, but no `val` or `var` keyword, `val` is assumed.
+ A formal parameter prefixed by `val` or `var` may not at the same time be a [call-by-name parameter](#by-name-parameters).
+
- $t$ is a [template](#templates) of the form
```