diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2015-06-22 02:02:42 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2015-06-22 02:03:02 +0200 |
commit | a74bdc72efe0c59e7ae8269f00e0941fbe0c0c0c (patch) | |
tree | bc7daaa4cf0fe9b7e2a01e1dcebcfe68e3409f7b /spec/05-classes-and-objects.md | |
parent | a3beedac5b957e3954be288b1be7c52a1d7d31b0 (diff) | |
download | scala-a74bdc72efe0c59e7ae8269f00e0941fbe0c0c0c.tar.gz scala-a74bdc72efe0c59e7ae8269f00e0941fbe0c0c0c.tar.bz2 scala-a74bdc72efe0c59e7ae8269f00e0941fbe0c0c0c.zip |
Spec: Add lost references, cleanup
Diffstat (limited to 'spec/05-classes-and-objects.md')
-rw-r--r-- | spec/05-classes-and-objects.md | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/spec/05-classes-and-objects.md b/spec/05-classes-and-objects.md index 8be792d3cb..cff5442641 100644 --- a/spec/05-classes-and-objects.md +++ b/spec/05-classes-and-objects.md @@ -501,14 +501,13 @@ declaration in a template. Such members can be accessed only from within the directly enclosing template and its companion module or [companion class](#object-definitions). -The modifier can be _qualified_ with an identifier $C$ (e.g. -`private[$C$]`) that must denote a class or package -enclosing the definition. Members labeled with such a modifier are -accessible respectively only from code inside the package $C$ or only -from code inside the class $C$ and its +A `private` modifier can be _qualified_ with an identifier $C$ (e.g. +`private[$C$]`) that must denote a class or package enclosing the definition. +Members labeled with such a modifier are accessible respectively only from code +inside the package $C$ or only from code inside the class $C$ and its [companion module](#object-definitions). -An different form of qualification is `private[this]`. A member +A different form of qualification is `private[this]`. A member $M$ marked with this modifier is called _object-protected_; it can be accessed only from within the object in which it is defined. That is, a selection $p.M$ is only legal if the prefix is `this` or `$O$.this`, for some @@ -533,11 +532,10 @@ Protected members of a class can be accessed from within - all templates that have the defining class as a base class, - the companion module of any of those classes. -A `protected` modifier can be qualified with an -identifier $C$ (e.g. `protected[$C$]`) that must denote a -class or package enclosing the definition. Members labeled with such -a modifier are also accessible respectively from all code inside the -package $C$ or from all code inside the class $C$ and its +A `protected` modifier can be qualified with an identifier $C$ (e.g. +`protected[$C$]`) that must denote a class or package enclosing the definition. +Members labeled with such a modifier are also accessible respectively from all +code inside the package $C$ or from all code inside the class $C$ and its [companion module](#object-definitions). A protected identifier $x$ may be used as a member name in a selection @@ -744,7 +742,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 – `val` and `var` parameters The following example illustrates `val` and `var` parameters of a class `C`: ```scala @@ -753,7 +751,7 @@ val c = new C(1, "abc", List()) c.z = c.y :: c.z ``` -### Example Private Constructor +###### Example – Private Constructor The following class can be created only from its companion module. ```scala @@ -835,7 +833,7 @@ This defines a class `LinkedList` with three constructors. The second constructor constructs an singleton list, while the third one constructs a list with a given head and tail. -## Case Classes +### Case Classes ```ebnf TmplDef ::= `case' `class' ClassDef |