From 99ede604a0a16dc0a63383cd90f8b7d38c4f8fd3 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 7 Jul 2009 13:22:17 +0000 Subject: minor change (Scala comments) --- src/library/scala/annotation/switch.scala | 7 ++- .../collection/generic/ImmutableMapTemplate.scala | 10 ++-- .../collection/generic/MutableMapTemplate.scala | 57 +++++++++++++-------- src/library/scala/reflect/Invocation.scala | 58 ++++++++++++---------- src/library/scala/remote.scala | 3 -- src/library/scala/testing/Show.scala | 36 ++++++++++---- 6 files changed, 106 insertions(+), 65 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/annotation/switch.scala b/src/library/scala/annotation/switch.scala index 1dfd0af88d..7a888ce904 100644 --- a/src/library/scala/annotation/switch.scala +++ b/src/library/scala/annotation/switch.scala @@ -10,8 +10,11 @@ package scala.annotation /**

* An annotation to be applied to a match expression. If present, * the compiler will verify that the match has been compiled to a - * tableswitch or lookupswitch, and issue an error if it instead - * compiles into a series of conditional expressions.
+ * tableswitch or + * lookupswitch, and issue an error if it + * instead compiles into a series of conditional expressions.
* Example: *

*
diff --git a/src/library/scala/collection/generic/ImmutableMapTemplate.scala b/src/library/scala/collection/generic/ImmutableMapTemplate.scala
index bf21c26a25..5fbf3fda21 100644
--- a/src/library/scala/collection/generic/ImmutableMapTemplate.scala
+++ b/src/library/scala/collection/generic/ImmutableMapTemplate.scala
@@ -28,7 +28,7 @@ package scala.collection.generic
  *    filter return the same kind of map, you should also override:
  *  

*
- *    def empty: This
+ *    def empty: This
*

* It is also good idea to override methods foreach and * size for efficiency. @@ -96,9 +96,11 @@ self => * p returns true. * * @param p A predicate over key-value pairs - * @note This method works by successively removing elements fro which the predicate is false from this set. - * If removal is slow, or you expect that most elements of the set will be removed, - * you might consider using `filter` with a negated predicate instead. + * @note This method works by successively removing elements fro which the + * predicate is false from this set. + * If removal is slow, or you expect that most elements of the set$ + * will be removed, you might consider using filter + * with a negated predicate instead. */ override def filterNot(p: ((A, B)) => Boolean): This = { var res: This = thisCollection diff --git a/src/library/scala/collection/generic/MutableMapTemplate.scala b/src/library/scala/collection/generic/MutableMapTemplate.scala index c5a4566e69..62ae9671c7 100644 --- a/src/library/scala/collection/generic/MutableMapTemplate.scala +++ b/src/library/scala/collection/generic/MutableMapTemplate.scala @@ -11,23 +11,33 @@ package scala.collection.generic -/** A generic template for mutable maps from keys of type A to values of type B. - * To implement a concrete mutable map, you need to provide implementations of the following methods: - * - * def get(key: A): Option[B] - * def iterator: Iterator[(A, B)] - * def += (kv: (A, B)): this.type - * def -= (key: A): this.type - * - * If you wish that methods like, take, drop, filter return the same kind of map, you should also - * override: - * - * def empty: This - * - * If you to avoid the unncessary construction of an Option object, - * you could also override apply, update, and delete. - * It is also good idea to override methods `foreach` and `size` for efficiency. - * +/**

+ * A generic template for mutable maps from keys of type A to + * values of type B. + *

+ *

+ * To implement a concrete mutable map, you need to provide implementations + * of the following methods: + *

+ *    def get(key: A): Option[B]
+ *    def iterator: Iterator[(A, B)]
+ *    def += (kv: (A, B)): this.type
+ *    def -= (key: A): this.type
+ *

+ * If you wish that methods like, take, + * drop, filter return the same kind of map, you + * should also override: + *

+ *   def empty: This
+ *

+ * If you to avoid the unncessary construction of an Option + * object, you could also override apply, update, + * and delete. + *

+ *

+ * It is also good idea to override methods foreach and + * size for efficiency. + *

*/ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with mutable.Map[A, B]] extends MutableMapTemplateBase[A, B, This] @@ -37,8 +47,13 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta with Cloneable[This] { self => - /** A common implementation of `newBuilder` for all mutable maps in terms of `empty`. - * Overrides `MapTemplate` implementation for better efficiency. + /**

+ * A common implementation of newBuilder for all mutable maps + * in terms of empty. + *

+ *

+ * Overrides MapTemplate implementation for better efficiency. + *

*/ override protected[this] def newBuilder: Builder[(A, B), This] = empty @@ -58,6 +73,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta /** Adds a new mapping from key * to value to the map. If the map already contains a * mapping for key, it will be overridden. + * * @param key The key to update * @param value The new value * @return An option consisting of value associated previously associated with `key` in the map, @@ -72,7 +88,8 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta def += (kv: (A, B)): this.type /** Create a new map consisting of all elements of the current map - * plus the given mapping from `key` to `value`. + * plus the given mapping from key to value. + * * @param key The key to ad * @param value The new value * @return A fresh immutable map diff --git a/src/library/scala/reflect/Invocation.scala b/src/library/scala/reflect/Invocation.scala index d0ef9676d4..b2d3396cd9 100644 --- a/src/library/scala/reflect/Invocation.scala +++ b/src/library/scala/reflect/Invocation.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id$ +// $Id: $ package scala.reflect @@ -17,36 +17,42 @@ import java.lang.{ Class => JClass } import java.lang.reflect.{ Method => JMethod } import scala.{ Symbol => ScalaSymbol } -/** A more convenient syntax for reflective invocation. Example usage: - * - * class Obj { private def foo(x: Int, y: String): Long = x + y.length } - * - * You can call it reflectively one of two ways: - * - * import scala.reflect.Invocation._ - * (new Obj) o 'foo(5, "abc") // the 'o' method returns Any - * val x: Long = (new Obj) oo 'foo(5, "abc") // the 'oo' method casts to expected type. - * - * If you call the 'oo' method and do not give the type inferencer enough help, - * it will most likely infer Nothing, which will result in a ClassCastException. +/**

+ * A more convenient syntax for reflective invocation.
+ * Example usage: + *

+ *    class Obj { private def foo(x: Int, y: String): Long = x + y.length }
+ *

+ * You can call it reflectively one of two ways: + *

+ *    import scala.reflect.Invocation._
+ *    (new Obj) o 'foo(5, "abc")                 // the 'o' method returns Any
+ *    val x: Long = (new Obj) oo 'foo(5, "abc")  // the 'oo' method casts to expected type.
+ *

+ * If you call the oo method and do not give the type inferencer + * enough help, it will most likely infer Nothing, which will + * result in a ClassCastException. + *

* * @author Paul Phillips - * */ @experimental object Invocation { - /** In order to encapsulate anything to do with reflection, we must - * overcome an issue with the boxing of primitives. If we declare a - * method which takes arguments of type Any, by the time the method - * parameters can be examined, the primitives have already been boxed. - * The reflective call will then fail because classOf[java.lang.Integer] - * is not the same thing as classOf[scala.Int]. - * - * Any useful workaround will require examining the arguments before - * the method is called. The approach here is to define two implicits, - * one for AnyRefs and one for AnyVals, and box them in a container - * which preserves their original class identity. + /**

+ * In order to encapsulate anything to do with reflection, we must + * overcome an issue with the boxing of primitives. If we declare a + * method which takes arguments of type Any, by the time the + * method parameters can be examined, the primitives have already been boxed. + * The reflective call will then fail because classOf[java.lang.Integer] + * is not the same thing as classOf[scala.Int]. + *

+ *

+ * Any useful workaround will require examining the arguments before + * the method is called. The approach here is to define two implicits, + * one for AnyRef's and one for AnyVal's, and + * box them in a container which preserves their original class identity. + *

*/ trait PrimitivePreserver[T] { val value: T @@ -112,7 +118,7 @@ object Invocation implicit def makeReflectionOperators[T <: AnyRef](x: T): ReflectionOperators[T] = new ReflectionOperators(x) - /** Obtain the class object for an AnyVal. + /** Obtain the class object for an AnyVal. */ def getAnyValClass(x: AnyVal): JClass[_] = x match { case _: Byte => classOf[Byte] diff --git a/src/library/scala/remote.scala b/src/library/scala/remote.scala index 5208417807..612b6661e5 100644 --- a/src/library/scala/remote.scala +++ b/src/library/scala/remote.scala @@ -13,8 +13,5 @@ package scala /** * An annotation that designates the class to which it is applied as remotable. - * - * @see Method $tag in trait - * scala.ScalaObject. */ class remote extends StaticAnnotation {} diff --git a/src/library/scala/testing/Show.scala b/src/library/scala/testing/Show.scala index 32d32d4a0c..ed1684d99b 100644 --- a/src/library/scala/testing/Show.scala +++ b/src/library/scala/testing/Show.scala @@ -1,18 +1,34 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + + package scala.testing -/** Classes inheriting trait `Show` can test their member methods using the notattion - * 'meth(arg_1, ..., arg_n), where `meth' is the name of the method and `arg_1,...,arg_n' are - * the arguments. The only difference to a normal method call is the leading quote character ('). - * A quoted method call like the one above will produces a legible diagnostic to be printed on Console. - * It is of the form - * - * meth(arg_1, ..., arg_n) gives - * - * where is the result of evaluating the call. +/**

+ * Classes inheriting trait Show can test their member methods + * using the notattion meth(arg1, ..., argn), + * where meth is the name of the method and + * arg1,...,argn are the arguments. + * The only difference to a normal method call is the leading quote + * character ('). A quoted method call like the one above will produces a + * legible diagnostic to be printed on Console. It is of the form + *

+ *    meth(arg1, ..., argn)  gives  <result>
+ *

+ * where <result> is the result of evaluating the call. + *

*/ trait Show { - /** The result class of wrapper `symApply`. + /** The result class of wrapper symApply. * Prints out diagnostics of method applications. */ class SymApply(f: Symbol) { -- cgit v1.2.3