Skip to content
Browse files

Miscellaneous cleanups:

- Value of Unit is (), not {}
- Fix desugared pattern matching code
- Mention object-protected values
- Use uppercase type variables for Tuple/Function code
- Replace Application with App
  • Loading branch information...
1 parent 2311e34 commit 50ce3228b80475d1a0d748ec40ef532afb96df8f @soc soc committed with iainmcgin Feb 21, 2013
View
4 05-types.md
@@ -232,10 +232,10 @@ implement other traits).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
case class Tuple$n$[+T1, … , +$T_n$](_1: T1, … , _n: $T_n$)
-extends Product_n[T1, … , $T_n$] {}
+extends Product_n[T1, … , $T_n$]
trait Product_n[+T1, … , +$T_n$] {
- override def arity = $n$
+ override def productArity = $n$
def _1: T1
def _n: $T_n$
View
12 06-basic-declarations-and-definitions.md
@@ -83,7 +83,7 @@ value definition `val $p$ = $e$` is expanded as follows:
1. If the pattern $p$ has bound variables $x_1 , \ldots , x_n$, where $n > 1$:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
-val $\$ x$ = $e$ match {case $p$ => {$x_1 , \ldots , x_n$}}
+val $\$ x$ = $e$ match {case $p$ => ($x_1 , \ldots , x_n$)}
val $x_1$ = $\$ x$._1
$\ldots$
val $x_n$ = $\$ x$._n .
@@ -117,7 +117,7 @@ $e$ match { case $p$ => ()}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
val x = f() match { case Some(x) => x }
- val x$\$$ = mylist match { case x :: xs => {x, xs} }
+ val x$\$$ = mylist match { case x :: xs => (x, xs) }
val x = x$\$$._1
val xs = x$\$$._2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -184,7 +184,7 @@ type $T$ as follows:
`0.0f` if $T$ is `Float`
`0.0d` if $T$ is `Double`
`false` if $T$ is `Boolean`
-`{}` if $T$ is `Unit`
+`()` if $T$ is `Unit`
`null` for all other types $T$
---------- --------------------------------------------------
@@ -444,7 +444,7 @@ changes at the following constructs.
<!-- TODO: handle type aliases -->
References to the type parameters in
-[object-private values, variables, or methods](#modifiers) of the class are not
+[object-private or object-protected values, variables, or methods](#modifiers) of the class are not
checked for their variance position. In these members the type parameter may
appear anywhere without restricting its legal variance annotations.
@@ -708,10 +708,10 @@ FunDef ::= FunSig [nl] ‘{’ Block ‘}’
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Special syntax exists for procedures, i.e.\ functions that return the
-\verb@Unit@ value \verb@{}@.
+`Unit` value `()`.
A procedure declaration is a function declaration where the result type
is omitted. The result type is then implicitly completed to the
-\verb@Unit@ type. E.g., `def $f$($\mathit{ps}$)` is equivalent to
+`Unit` type. E.g., `def $f$($\mathit{ps}$)` is equivalent to
`def $f$($\mathit{ps}$): Unit`.
A procedure definition is a function definition where the result type
View
2 07-classes-and-objects.md
@@ -524,7 +524,7 @@ the validity and meaning of a modifier are as follows.
from templates inside $C$.
An different form of qualification is `private[this]`. A member
- $M$ marked with this modifier can be accessed only from within
+ $M$ marked with this modifier is called {\em 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
class $O$ enclosing the reference. In addition, the restrictions for
View
15 11-top-level-definitions.md
@@ -155,8 +155,8 @@ passed to the `main` method as a parameter of type
`Array[String]`.
The `main` method of a program can be directly defined in the
-object, or it can be inherited. The scala library defines a class
-`scala.Application` that defines an empty inherited `main` method.
+object, or it can be inherited. The scala library defines a special class
+`scala.App` whose body acts as a `main` method.
An objects $m$ inheriting from this class is thus a program,
which executes the initializaton code of the object $m$.
@@ -165,12 +165,13 @@ which executes the initializaton code of the object $m$.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package test
- object HelloWord {
- def main(args: Array[String]) { println("hello world") }
+ object HelloWorld {
+ def main(args: Array[String]) { println("Hello World") }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program can be started by the command
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scala test.HelloWorld
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -184,12 +185,12 @@ which executes the initializaton code of the object $m$.
would work as well.
`HelloWorld` can also be defined without a `main` method
- by inheriting from `Application` instead:
+ by inheriting from `App` instead:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package test
- object HelloWord extends Application {
- println("hello world")
+ object HelloWorld extends App {
+ println("Hello World")
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View
6 14-the-scala-standard-library.md
@@ -365,7 +365,7 @@ These are defined as follows.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package scala
-case class Tuple$n$[+a_1, ..., +a_n](_1: a_1, ..., _$n$: a_$n$) {
+case class Tuple$n$[+A_1, ..., +A_n](_1: A_1, ..., _$n$: A_$n$) {
def toString = "(" ++ _1 ++ "," ++ $\ldots$ ++ "," ++ _$n$ ++ ")"
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -381,8 +381,8 @@ These are defined as follows.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.scala}
package scala
-trait Function$n$[-a_1, ..., -a_$n$, +b] {
- def apply(x_1: a_1, ..., x_$n$: a_$n$): b
+trait Function$n$[-A_1, ..., -A_$n$, +B] {
+ def apply(x_1: A_1, ..., x_$n$: A_$n$): B
def toString = "<function>"
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 comments on commit 50ce322

Please sign in to comment.
Something went wrong with that request. Please try again.