summaryrefslogtreecommitdiff
path: root/04-identifiers-names-and-scopes.md
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-11 17:20:13 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-11 17:37:41 -0700
commit9fb82769f4cdc51198a7252e117a2a3828e7b00e (patch)
tree7807ea639db4f19cee2abbfa85a19061e31ba320 /04-identifiers-names-and-scopes.md
parent19ab789a37ce429550ee8ca6e20f00111ff76b54 (diff)
downloadscala-9fb82769f4cdc51198a7252e117a2a3828e7b00e.tar.gz
scala-9fb82769f4cdc51198a7252e117a2a3828e7b00e.tar.bz2
scala-9fb82769f4cdc51198a7252e117a2a3828e7b00e.zip
github markdown: use ###### for examples
Diffstat (limited to '04-identifiers-names-and-scopes.md')
-rw-r--r--04-identifiers-names-and-scopes.md78
1 files changed, 40 insertions, 38 deletions
diff --git a/04-identifiers-names-and-scopes.md b/04-identifiers-names-and-scopes.md
index 1e74e52b5f..7caedb0241 100644
--- a/04-identifiers-names-and-scopes.md
+++ b/04-identifiers-names-and-scopes.md
@@ -54,44 +54,46 @@ is bound by a definition or declaration, then $x$ refers to the entity
introduced by that binding. In that case, the type of $x$ is the type
of the referenced entity.
-(@) Assume the following two definitions of a objects named `X` in packages `P` and `Q`.
-
- ```
- package P {
- object X { val x = 1; val y = 2 }
- }
-
- package Q {
- object X { val x = true; val y = "" }
- }
- ```
-
- The following program illustrates different kinds of bindings and
- precedences between them.
-
- ```
- package P { // `X' bound by package clause
- import Console._ // `println' bound by wildcard import
- object A {
- println("L4: "+X) // `X' refers to `P.X' here
- object B {
- import Q._ // `X' bound by wildcard import
- println("L7: "+X) // `X' refers to `Q.X' here
- import X._ // `x' and `y' bound by wildcard import
- println("L8: "+x) // `x' refers to `Q.X.x' here
- object C {
- val x = 3 // `x' bound by local definition
- println("L12: "+x) // `x' refers to constant `3' here
- { import Q.X._ // `x' and `y' bound by wildcard import
- // println("L14: "+x) // reference to `x' is ambiguous here
- import X.y // `y' bound by explicit import
- println("L16: "+y) // `y' refers to `Q.X.y' here
- { val x = "abc" // `x' bound by local definition
- import P.X._ // `x' and `y' bound by wildcard import
- // println("L19: "+y) // reference to `y' is ambiguous here
- println("L20: "+x) // `x' refers to string ``abc'' here
- }}}}}}
- ```
+###### Example: bindings
+
+Assume the following two definitions of a objects named `X` in packages `P` and `Q`.
+
+```
+package P {
+ object X { val x = 1; val y = 2 }
+}
+
+package Q {
+ object X { val x = true; val y = "" }
+}
+```
+
+The following program illustrates different kinds of bindings and
+precedences between them.
+
+```
+package P { // `X' bound by package clause
+import Console._ // `println' bound by wildcard import
+object A {
+ println("L4: "+X) // `X' refers to `P.X' here
+ object B {
+ import Q._ // `X' bound by wildcard import
+ println("L7: "+X) // `X' refers to `Q.X' here
+ import X._ // `x' and `y' bound by wildcard import
+ println("L8: "+x) // `x' refers to `Q.X.x' here
+ object C {
+ val x = 3 // `x' bound by local definition
+ println("L12: "+x) // `x' refers to constant `3' here
+ { import Q.X._ // `x' and `y' bound by wildcard import
+// println("L14: "+x) // reference to `x' is ambiguous here
+ import X.y // `y' bound by explicit import
+ println("L16: "+y) // `y' refers to `Q.X.y' here
+ { val x = "abc" // `x' bound by local definition
+ import P.X._ // `x' and `y' bound by wildcard import
+// println("L19: "+y) // reference to `y' is ambiguous here
+ println("L20: "+x) // `x' refers to string ``abc'' here
+}}}}}}
+```
A reference to a qualified (type- or term-) identifier $e.x$ refers to
the member of the type $T$ of $e$ which has the name $x$ in the same