summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-11-02 10:35:47 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-11-02 10:35:47 -0700
commitf8ed076e251ff8b6e2b1d27f8c8a0dde2117308d (patch)
tree86e6126f78ffe707684e109c706bd51c2350052e /src/library
parent59149579aec4b3d26a4cb849d80535a36b90ad30 (diff)
parent093b8e1b6fdb88eab0739b21b4e3b4815be0795f (diff)
downloadscala-f8ed076e251ff8b6e2b1d27f8c8a0dde2117308d.tar.gz
scala-f8ed076e251ff8b6e2b1d27f8c8a0dde2117308d.tar.bz2
scala-f8ed076e251ff8b6e2b1d27f8c8a0dde2117308d.zip
Merge pull request #1558 from heathermiller/doc/reflection-errata
API docs: reflection fixes, AnyVal/Any documentation additions, errata
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/AnyVal.scala37
-rw-r--r--src/library/scala/concurrent/Future.scala2
2 files changed, 33 insertions, 6 deletions
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index d637527b30..ebdc963946 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -9,8 +9,8 @@
package scala
/** `AnyVal` is the root class of all ''value types'', which describe values
- * not implemented as objects in the underlying host system. The value classes
- * are specified in SLS 12.2.
+ * not implemented as objects in the underlying host system. Value classes
+ * are specified in Scala Language Specification, section 12.2.
*
* The standard implementation includes nine `AnyVal` subtypes:
*
@@ -21,9 +21,36 @@ package scala
*
* Other groupings:
*
- * The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]].
- * The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
- * The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
+ * - The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]].
+ * - The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
+ * - The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
+ *
+ * Prior to Scala 2.10, `AnyVal` was a sealed trait. Beginning with Scala 2.10,
+ * however, it is possible to define a subclass of `AnyVal` called a ''user-defined value class''
+ * which is treated specially by the compiler. Properly-defined user value classes provide a way
+ * to improve performance on user-defined types by avoiding object allocation at runtime, and by
+ * replacing virtual method invocations with static method invocations.
+ *
+ * User-defined value classes which avoid object allocation...
+ *
+ * - must have a single, public `val` parameter that is the underlying runtime representation.
+ * - can define `def`s, but no `val`s, `var`s, or nested `traits`s, `class`es or `object`s.
+ * - typically extend no other trait apart from `AnyVal`.
+ * - cannot be used in type tests or pattern matching.
+ * - may not override `equals` or `hashCode` methods.
+ *
+ * A minimal example:
+ * {{{
+ * class Wrapper(val underlying: Int) extends AnyVal {
+ * def foo: Wrapper = new Wrapper(underlying * 19)
+ * }
+ * }}}
+ *
+ * It's important to note that user-defined value classes are limited, and in some circumstances,
+ * still must allocate a value class instance at runtime. These limitations and circumstances are
+ * explained in greater detail in the [[http://docs.scala-lang.org/overviews/core/value-classes.html Value Classes Guide]]
+ * as well as in [[http://docs.scala-lang.org/sips/pending/value-classes.html SIP-15: Value Classes]],
+ * the Scala Improvement Proposal.
*/
abstract class AnyVal extends Any with NotNull {
def getClass(): Class[_ <: AnyVal] = null
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 111900e7bc..f308b674bb 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -58,7 +58,7 @@ import scala.reflect.ClassTag
* Instead, the future is completed with a ExecutionException with one of the exceptions above
* as the cause.
* If a future is failed with a `scala.runtime.NonLocalReturnControl`,
- * it is completed with a value instead from that throwable instead instead.
+ * it is completed with a value from that throwable instead.
*
* @define nonDeterministic
* Note: using this method yields nondeterministic dataflow programs.