summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-05-21 08:32:16 +0000
committermichelou <michelou@epfl.ch>2007-05-21 08:32:16 +0000
commitef2279df3d7f3cb4b120e323bc67cac8f60f3e57 (patch)
tree9c6cdfc4d72427bafc4c4f10e2a8b7bb2e31cb21
parent77863427aeaae8c34ae95595eafa5bf0a2d8e69a (diff)
downloadscala-ef2279df3d7f3cb4b120e323bc67cac8f60f3e57.tar.gz
scala-ef2279df3d7f3cb4b120e323bc67cac8f60f3e57.tar.bz2
scala-ef2279df3d7f3cb4b120e323bc67cac8f60f3e57.zip
minor changes
-rw-r--r--build.xml6
-rw-r--r--debian/copyright2
-rw-r--r--docs/README17
-rw-r--r--src/actors/scala/actors/remote/Serializer.scala4
-rw-r--r--src/actors/scala/actors/remote/Service.scala7
-rw-r--r--src/compiler/scala/tools/util/AbstractTimer.scala11
-rw-r--r--src/compiler/scala/tools/util/SocketConnection.scala8
-rw-r--r--src/compiler/scala/tools/util/SocketServer.scala7
-rw-r--r--src/compiler/scala/tools/util/StringOps.scala4
-rw-r--r--src/compiler/scala/tools/util/UTF8Codec.scala21
-rw-r--r--src/library/scala/testing/Benchmark.scala16
-rw-r--r--src/library/scala/testing/SUnit.scala39
-rw-r--r--src/library/scala/testing/UnitTest.scala16
-rw-r--r--src/library/scala/text/Document.scala22
-rw-r--r--src/library/scala/util/Fluid.scala73
-rw-r--r--src/library/scala/util/Sorting.scala108
16 files changed, 193 insertions, 168 deletions
diff --git a/build.xml b/build.xml
index 0d7ba9dcbc..23f4bfffc9 100644
--- a/build.xml
+++ b/build.xml
@@ -1002,7 +1002,7 @@ GENERATES A DISTRIBUTION
regexp="([^-]*)(-.*)?" select="\1"
/>
<echo level="verbose" message="OSGi version: ${osgi.version.number}"/>
- <jar destfile="${dist.current.dir}/lib/${comp.jar.name}">
+ <jar destfile="${dist.current.dir}/lib/${comp.jar.name}" index="true">
<fileset dir="${strap.dir}/lib/compiler"/>
<zipfileset src="${fjbg.jar}"/>
<zipfileset src="${msil.jar}"/>
@@ -1031,7 +1031,7 @@ GENERATES A DISTRIBUTION
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
</manifest>
</jar>
- <jar destfile="${dist.current.dir}/lib/${lib.jar.name}">
+ <jar destfile="${dist.current.dir}/lib/${lib.jar.name}" index="true">
<fileset dir="${strap.dir}/lib/library"/>
<fileset dir="${strap.dir}/lib/actors"/>
<manifest>
@@ -1058,7 +1058,7 @@ GENERATES A DISTRIBUTION
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
</manifest>
</jar>
- <jar destfile="${dist.current.dir}/lib/${dbc.jar.name}">
+ <jar destfile="${dist.current.dir}/lib/${dbc.jar.name}" index="true">
<fileset dir="${strap.dir}/lib/dbc"/>
<manifest>
<attribute name="Signature-Version" value="${version.number}"/>
diff --git a/debian/copyright b/debian/copyright
index c686dc2a67..925e31acfc 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -8,7 +8,7 @@ This package was originally assembled by Lex Spoon (lex@debian.org).
SCALA LICENSE
-Copyright (c) 2002-2006 EPFL, Lausanne, unless otherwise specified.
+Copyright (c) 2002-2007 EPFL, Lausanne, unless otherwise specified.
All rights reserved.
This software was developed by the Programming Methods Laboratory of the
diff --git a/docs/README b/docs/README
index f239cc3395..f63f2e2fa9 100644
--- a/docs/README
+++ b/docs/README
@@ -13,19 +13,20 @@ know which version of Java you have, run the command "java -version".
Scala Tools
-----------
+- fsc Scala offline compiler
- scalac Scala compiler
- scaladoc Scala API documentation generator
-- scalaint Scala interactive interpreter
+- scala Scala interactive interpreter
- scalap Scala classfile decoder
Run the command "scalac -help" to display the list of available
compiler options.
-Install on Unix
----------------
+Unix Installation
+-----------------
-Untar the archive. All Scala tools are located in the directory "bin".
+Untar the archive. All Scala tools are located in the "bin" directory.
Adding that directory to the PATH variable will make the Scala commands
directly accessible.
@@ -35,7 +36,7 @@ $ ./bin/scalac share/doc/scala/examples/sort.scala
$ ./bin/scala examples.sort
[6,2,8,5,1]
[1,2,5,6,8]
-$ ./bin/scalaint
+$ ./bin/scala
scala> examples.sort.main(null)
[6,2,8,5,1]
[1,2,5,6,8]
@@ -43,8 +44,8 @@ scala>:quit
$
-Install on Windows
-------------------
+Windows Installation
+--------------------
Unzip the archive. All Scala tools are located in the "bin" directory.
Adding that directory to the PATH variable will make the Scala commands
@@ -55,7 +56,7 @@ to point to the home directory of the Scala distribution to run any of
these tools. This can be done by adding the following command to your
AUTOEXEC.BAT file and then rebooting your machine.
-set SCALA_HOME=<install-directory>\scala-YYYYMMDD-hhmmss
+set SCALA_HOME=<install-directory>\scala-<major>.<minor>.<patch>
On Windows NT/2000/XP, you do not need to define any variable in order
for the Scala commands to run correctly.
diff --git a/src/actors/scala/actors/remote/Serializer.scala b/src/actors/scala/actors/remote/Serializer.scala
index 2532e63dfe..6e71171997 100644
--- a/src/actors/scala/actors/remote/Serializer.scala
+++ b/src/actors/scala/actors/remote/Serializer.scala
@@ -41,7 +41,7 @@ abstract class Serializer(val service: Service) {
}
@throws(classOf[IOException])
- def writeBytes(outputStream: DataOutputStream, bytes: Array[byte]): unit = {
+ def writeBytes(outputStream: DataOutputStream, bytes: Array[byte]) {
val length = bytes.length;
// original length
outputStream.writeInt(length)
@@ -50,7 +50,7 @@ abstract class Serializer(val service: Service) {
}
@throws(classOf[IOException])
- def writeObject(outputStream: DataOutputStream, obj: AnyRef) = {
+ def writeObject(outputStream: DataOutputStream, obj: AnyRef) {
val bytes = serialize(obj)
writeBytes(outputStream, bytes)
}
diff --git a/src/actors/scala/actors/remote/Service.scala b/src/actors/scala/actors/remote/Service.scala
index 819e039c6d..10bdd3edcf 100644
--- a/src/actors/scala/actors/remote/Service.scala
+++ b/src/actors/scala/actors/remote/Service.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -10,6 +10,9 @@
package scala.actors.remote
+/**
+ * @author Philipp Haller
+ */
trait Service {
val kernel = new NetKernel(this)
val serializer: Serializer
diff --git a/src/compiler/scala/tools/util/AbstractTimer.scala b/src/compiler/scala/tools/util/AbstractTimer.scala
index f734692a79..0fe9625197 100644
--- a/src/compiler/scala/tools/util/AbstractTimer.scala
+++ b/src/compiler/scala/tools/util/AbstractTimer.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -35,19 +35,20 @@ abstract class AbstractTimer {
def issue(message: String, duration: Long): Unit
/** Starts a new timer. */
- def start() = {
+ def start() {
starts += currentTime
}
/** Ends the current timer. */
- def stop(message: String): Unit = {
+ def stop(message: String) {
val stop = currentTime
issue(message, stop - starts.pop)
}
/** Drops the current timer. */
- def drop(): Unit =
+ def drop() {
starts.pop
+ }
//########################################################################
}
diff --git a/src/compiler/scala/tools/util/SocketConnection.scala b/src/compiler/scala/tools/util/SocketConnection.scala
index c1a9fb2a20..7936cfea72 100644
--- a/src/compiler/scala/tools/util/SocketConnection.scala
+++ b/src/compiler/scala/tools/util/SocketConnection.scala
@@ -1,12 +1,12 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $id: $
+// $Id$
package scala.tools.util
@@ -45,7 +45,7 @@ class SocketConnection(hostname: String, port: Int) {
}
}
- def close() = {
+ def close() {
in.close()
out.close()
socket.close()
diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala
index 06b732c6cb..cfa5b3170e 100644
--- a/src/compiler/scala/tools/util/SocketServer.scala
+++ b/src/compiler/scala/tools/util/SocketServer.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -46,7 +46,7 @@ abstract class SocketServer {
fatal("Could not listen on any port; exiting.")
}
- def run(): unit =
+ def run() {
while (!shutDown) {
val serverSocket = try {
new ServerSocket(port)
@@ -75,6 +75,7 @@ abstract class SocketServer {
clientSocket.close()
serverSocket.close()
}
+ }
}
diff --git a/src/compiler/scala/tools/util/StringOps.scala b/src/compiler/scala/tools/util/StringOps.scala
index b1cd5d9b1a..98c0934f19 100644
--- a/src/compiler/scala/tools/util/StringOps.scala
+++ b/src/compiler/scala/tools/util/StringOps.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
diff --git a/src/compiler/scala/tools/util/UTF8Codec.scala b/src/compiler/scala/tools/util/UTF8Codec.scala
index d2d420c4b6..c082a3f0d7 100644
--- a/src/compiler/scala/tools/util/UTF8Codec.scala
+++ b/src/compiler/scala/tools/util/UTF8Codec.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -23,20 +23,20 @@ object UTF8Codec {
val end = from + len
while (i < end) {
val ch = src(i)
- i = i + 1
+ i += 1
if (ch < 128) {
dst(j) = ch.toByte
- j = j + 1
+ j += 1
}
else if (ch <= 0x3FF) {
dst(j) = (0xC0 | (ch >> 6)).toByte
dst(j+1) = (0x80 | (ch & 0x3F)).toByte
- j = j + 2
+ j += 2
} else {
dst(j) = (0xE0 | (ch >> 12)).toByte
dst(j+1) = (0x80 | ((ch >> 6) & 0x3F)).toByte
dst(j+2) = (0x80 | (ch & 0x3F)).toByte
- j = j + 3
+ j += 3
}
}
j
@@ -45,7 +45,6 @@ object UTF8Codec {
def encode(s: String, dst: Array[Byte], to: Int): Int =
encode(s.toCharArray(), 0, dst, to, s.length())
-
def encode(s: String): Array[Byte] = {
val dst = new Array[Byte](s.length() * 3)
val len = encode(s, dst, 0)
@@ -60,17 +59,17 @@ object UTF8Codec {
val end = from + len
while (i < end) {
var b = src(i) & 0xFF
- i = i + 1
+ i += 1
if (b >= 0xE0) {
b = ((b & 0x0F) << 12) | (src(i) & 0x3F) << 6
b = b | (src(i+1) & 0x3F)
- i = i + 2
+ i += 2
} else if (b >= 0xC0) {
b = ((b & 0x1F) << 6) | (src(i) & 0x3F)
- i = i + 1
+ i += 1
}
dst(j) = b.toChar
- j = j + 1
+ j += 1
}
j
}
diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala
index 77c5613572..7542635f5b 100644
--- a/src/library/scala/testing/Benchmark.scala
+++ b/src/library/scala/testing/Benchmark.scala
@@ -14,17 +14,17 @@ package scala.testing
import compat.Platform
-/** <code>Benchmark</code> can be used to quickly turn an existing
- * class into a benchmark. Here is a short example:
- *
- * <pre>
+/** <p>
+ * <code>Benchmark</code> can be used to quickly turn an existing
+ * class into a benchmark. Here is a short example:
+ * </p><pre>
* <b>object</b> sort1 <b>extends</b> Sorter <b>with</b> Benchmark {
* <b>def</b> run = sort(List.range(1, 1000))
* }
* </pre>
* <p>
- * The run method has to be defined by the user, who will perform
- * the timed operation there.
+ * The <code>run</code> method has to be defined by the user, who
+ * will perform the timed operation there.
* Run the benchmark as follows:
* </p>
* <pre>
@@ -34,6 +34,8 @@ import compat.Platform
* This will run the benchmark 5 times and log the execution times in
* a file called <code>times.log</code>
* </p>
+ *
+ * @author Burak Emir
*/
trait Benchmark {
@@ -67,7 +69,7 @@ trait Benchmark {
* consecutive runs, and the name of a log file where to
* append the times.
*/
- def main(args: Array[String]): Unit = {
+ def main(args: Array[String]) {
if (args.length > 1) {
val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite
if (args.length >= 3)
diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala
index 7c0f76303c..7449328816 100644
--- a/src/library/scala/testing/SUnit.scala
+++ b/src/library/scala/testing/SUnit.scala
@@ -39,26 +39,31 @@ import scala.collection.mutable.ArrayBuffer
* Console.println(tf.toString())
* }
* </pre>
+ * <p>
+ * The trait <code>TestConsoleMain</code> contains this code as
+ * a <code>main</code> method, for convenience.
+ * </p>
*
- * The trait TestConsoleMain contains this code as a main method, for convenience.
+ * @author Burak Emir
*/
object SUnit {
- /** convenience trait, mix it in a TestMain object and implement "suite" to get this code
+ /** convenience trait, mix it in a TestMain object and implement "suite" to get this code
* <b>val</b> r = <b>new</b> TestResult()
* suite.run(r)
* <b>for</b> (<b>val</b> tf &lt;- r.failures()) {
* Console.println(tf.toString())
- */
+ */
trait TestConsoleMain {
- def suite: TestSuite
- def main(args:Array[String]) {
+ def suite: TestSuite
+ def main(args: Array[String]) {
val r = new TestResult()
suite.run(r)
for (tf <- r.failures())
Console.println(tf.toString())
}
}
+
/** a Test can be run with its result being collected */
trait Test {
def run(r: TestResult): Unit
@@ -165,21 +170,23 @@ object SUnit {
assertNotNull("(no message)", actual)
/**
- * @deprecated use assertNotEq instead
- */
- @deprecated def assertNotSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit =
+ * @deprecated use assertNotEq instead
+ */
+ @deprecated
+ def assertNotSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit =
if (expected.eq(actual)) fail(msg)
/**
- * @deprecated use assertNotEq instead
+ * @deprecated use assertNotEq instead
*/
- @deprecated def assertNotSame(expected: => AnyRef, actual: => AnyRef): Unit =
+ @deprecated
+ def assertNotSame(expected: => AnyRef, actual: => AnyRef): Unit =
assertNotEq("(no message)", expected, actual)
/** fail if expected eq actual */
def assertNotEq(msg: String, expected: => AnyRef, actual: => AnyRef) {
if (expected eq actual) fail(msg)
- }
+ }
/** fail if expected eq actual */
def assertNotEq(expected: => AnyRef, actual: => AnyRef) {
@@ -195,14 +202,16 @@ object SUnit {
assertNull("(no message)", actual)
/**
- * @deprecated use assertEq instead
- */
+ * @deprecated use assertEq instead
+ */
+ @deprecated
def assertSame(msg: String, expected: => AnyRef, actual: => AnyRef): Unit =
if(!expected.eq(actual)) fail(msg)
/**
- * @deprecated use assertEq instead
- */
+ * @deprecated use assertEq instead
+ */
+ @deprecated
def assertSame(expected: => AnyRef, actual: => AnyRef): Unit =
assertEq("(no message)", expected, actual)
diff --git a/src/library/scala/testing/UnitTest.scala b/src/library/scala/testing/UnitTest.scala
index b6975a8e22..74c826044d 100644
--- a/src/library/scala/testing/UnitTest.scala
+++ b/src/library/scala/testing/UnitTest.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -11,19 +11,23 @@
package scala.testing
-
/**
* Some simple methods to support unit testing with assertions
* to contain more JUnit style assertions which use Scala's features.
- * @deprecated use SUnit instead
+ *
+ * @author Burak Emir
+ *
+ * @deprecated use <a href="SUnit.html" target="contentFrame">SUnit</a>
+ * instead.
*/
@deprecated
object UnitTest {
class Report(report_ok: () => Unit, report_fail: (String,String) => Unit) {
def ok(): Unit = report_ok()
- def fail(actual: String, expected: String): Unit =
+ def fail(actual: String, expected: String) {
report_fail(actual, expected)
+ }
}
var report = new Report(
@@ -36,7 +40,7 @@ object UnitTest {
/**
* @param r ...
*/
- def setReporter(r: Report) = {
+ def setReporter(r: Report) {
this.report = r
}
diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala
index 336ad30cc2..0808714c9d 100644
--- a/src/library/scala/text/Document.scala
+++ b/src/library/scala/text/Document.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -36,14 +36,14 @@ abstract class Document {
def :/:(hd: String): Document = hd :: DocBreak :: this
/**
- * Format this document on WRITER and try to set line breaks so that
- * the result fits in WIDTH columns.
+ * Format this document on <code>writer</code> and try to set line
+ * breaks so that the result fits in <code>width</code> columns.
*
* @param width ...
* @param writer ...
*/
- def format(width: Int, writer: Writer): Unit = {
- type FmtState = (Int,Boolean,Document)
+ def format(width: Int, writer: Writer) {
+ type FmtState = (Int, Boolean, Document)
def fits(w: Int, state: List[FmtState]): boolean = state match {
case _ if w < 0 =>
@@ -66,12 +66,12 @@ abstract class Document {
fits(w, (i, false, d) :: z)
}
- def spaces(n: Int): Unit = {
+ def spaces(n: Int) {
var rem = n
- while (rem >= 16) { writer write " "; rem = rem - 16 }
- if (rem >= 8) { writer write " "; rem = rem - 8 }
- if (rem >= 4) { writer write " "; rem = rem - 4 }
- if (rem >= 2) { writer write " "; rem = rem - 2}
+ while (rem >= 16) { writer write " "; rem -= 16 }
+ if (rem >= 8) { writer write " "; rem -= 8 }
+ if (rem >= 4) { writer write " "; rem -= 4 }
+ if (rem >= 2) { writer write " "; rem -= 2}
if (rem == 1) { writer write " " }
}
diff --git a/src/library/scala/util/Fluid.scala b/src/library/scala/util/Fluid.scala
index 78e749ee17..046ad2decc 100644
--- a/src/library/scala/util/Fluid.scala
+++ b/src/library/scala/util/Fluid.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -15,37 +15,42 @@ package scala.util
import Predef._
import java.lang.InheritableThreadLocal
-/** Fluids provide a binding mechanism where the current
- * value is found through <em>dynamic scope</em>, but where
- * access to the fluid itself is resolved through </em>static
- * binding</em> to a variable referencing the fluid.
- *
- * The current value can be retrieved with the
- * <code>value</code> method. New values can be
- * pushed using the <code>withValue</code> method.
- * Values pushed via <code>withValue</code> only
- * stay valid while the <code>withValue</code>'s
- * <em>second</em> argument, a parameterless closure,
- * executes. When the second argument finishes,
- * the fluid reverts to the previous value.
- *
- * Usage of <code>withValue</code> looks like this:
- * <blockquote><pre>
- * someFluid.withValue(newValue) {
- * // ... code called in here that calls value ...
- * // ... will be given back the newValue ...
- * }
- * </pre></blockquote>
- *
- * Each thread gets its own stack of bindings. When a
- * new thread is created, the fluid gets a copy of
- * the stack of bindings from the parent thread, and
- * from then on the bindings for the new thread
- * are independent of those for the original thread.
- *
- * @author Lex Spoon
- * @version 1.0, 21/03/2006
- */
+/** <p>
+ * Fluids provide a binding mechanism where the current
+ * value is found through <em>dynamic scope</em>, but where
+ * access to the fluid itself is resolved through </em>static
+ * binding</em> to a variable referencing the fluid.
+ * </p>
+ * <p>
+ * The current value can be retrieved with the
+ * <code>value</code> method. New values can be
+ * pushed using the <code>withValue</code> method.
+ * Values pushed via <code>withValue</code> only
+ * stay valid while the <code>withValue</code>'s
+ * <em>second</em> argument, a parameterless closure,
+ * executes. When the second argument finishes,
+ * the fluid reverts to the previous value.
+ * </p>
+ * <p>
+ * Usage of <code>withValue</code> looks like this:
+ * </p>
+ * <blockquote><pre>
+ * someFluid.withValue(newValue) {
+ * // ... code called in here that calls value ...
+ * // ... will be given back the newValue ...
+ * }
+ * </pre></blockquote>
+ * <p>
+ * Each thread gets its own stack of bindings. When a
+ * new thread is created, the fluid gets a copy of
+ * the stack of bindings from the parent thread, and
+ * from then on the bindings for the new thread
+ * are independent of those for the original thread.
+ * </p>
+ *
+ * @author Lex Spoon
+ * @version 1.0, 21/03/2006
+ */
class Fluid[T](init: T) {
private val tl = new InheritableThreadLocal {
override def initialValue = init.asInstanceOf[AnyRef]
@@ -71,7 +76,7 @@ class Fluid[T](init: T) {
}
/** Change the currently bound value, discarding the old value.
- * Usually withValue() gives better semantics.
+ * Usually <code>withValue()</code> gives better semantics.
*/
def value_=(newval: T) = { tl.set(newval) }
diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala
index 24f0de23c1..be5acbeed9 100644
--- a/src/library/scala/util/Sorting.scala
+++ b/src/library/scala/util/Sorting.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, Ross Judson **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -99,9 +99,9 @@ object Sorting {
var i = 0
while (i < n) {
swap(a, b)
- i = i + 1
- a = a + 1
- b = b + 1
+ i += 1
+ a += 1
+ b += 1
}
}
def med3(a: Int, b: Int, c: Int) = {
@@ -118,9 +118,9 @@ object Sorting {
var j = i
while (j > off && x(j-1) > x(j)) {
swap(j, j-1)
- j = j - 1
+ j -= 1
}
- i = i + 1
+ i += 1
}
} else {
// Choose a partition element, v
@@ -142,29 +142,29 @@ object Sorting {
var a = off
var b = a
var c = off + len - 1
- var d = c;
+ var d = c
var done = false
while(!done) {
while (b <= c && x(b) <= v) {
if (x(b) == v) {
swap(a, b)
- a = a + 1
+ a += 1
}
- b = b + 1
+ b += 1
}
while (c >= b && x(c) >= v) {
if (x(c) == v) {
swap(c, d)
- d = d - 1
+ d -= 1
}
- c = c - 1
+ c -= 1
}
if (b > c) {
done = true
} else {
swap(b, c)
- c = c - 1
- b = b + 1
+ c -= 1
+ b += 1
}
}
@@ -196,10 +196,10 @@ object Sorting {
var b = _b
var i = 0
while (i < n) {
- swap(a,b)
- i = i + 1
- a = a + 1
- b = b + 1
+ swap(a, b)
+ i += 1
+ a += 1
+ b += 1
}
}
def med3(a: Int, b: Int, c: Int) = {
@@ -216,9 +216,9 @@ object Sorting {
var j = i
while (j > off && x(j-1) > x(j)) {
swap(j, j-1)
- j = j - 1
+ j -= 1
}
- i = i + 1
+ i += 1
}
} else {
// Choose a partition element, v
@@ -246,28 +246,28 @@ object Sorting {
while (b <= c && x(b) <= v) {
if (x(b) == v) {
swap(a, b)
- a = a + 1
+ a += 1
}
- b = b + 1
+ b += 1
}
while (c >= b && x(c) >= v) {
if (x(c) == v) {
swap(c, d)
- d = d - 1
+ d -= 1
}
- c = c - 1
+ c -= 1
}
if (b > c) {
done = true
} else {
swap(b, c)
- c = c - 1
- b = b + 1
+ c -= 1
+ b += 1
}
}
// Swap partition elements back to middle
- val n = off + len;
+ val n = off + len
var s = Math.min(a-off, b-a)
vecswap(off, b-s, s)
s = Math.min(d-c, n-d-1)
@@ -295,9 +295,9 @@ object Sorting {
var i = 0
while (i < n) {
swap(a, b)
- i = i + 1
- a = a + 1
- b = b + 1
+ i += 1
+ a += 1
+ b += 1
}
}
def med3(a: Int, b: Int, c: Int) =
@@ -313,10 +313,10 @@ object Sorting {
while (i < len + off) {
var j = i
while (j>off && x(j-1)>x(j)) {
- swap(j,j-1)
- j = j - 1
+ swap(j, j-1)
+ j -= 1
}
- i = i + 1
+ i += 1
}
} else {
// Choose a partition element, v
@@ -344,23 +344,23 @@ object Sorting {
while (b <= c && x(b) <= v) {
if (x(b) == v) {
swap(a, b)
- a = a + 1
+ a += 1
}
- b = b + 1
+ b += 1
}
while (c >= b && x(c) >= v) {
if (x(c) == v) {
swap(c, d)
- d = d - 1
+ d -= 1
}
- c = c - 1
+ c -= 1
}
if (b > c) {
done = true
} else {
swap(b, c)
- c = c - 1
- b = b + 1
+ c -= 1
+ b += 1
}
}
@@ -392,10 +392,10 @@ object Sorting {
var b = _b
var i = 0
while (i < n) {
- swap(a,b)
- i = i + 1
- a = a + 1
- b = b + 1
+ swap(a, b)
+ i += 1
+ a += 1
+ b += 1
}
}
def med3(a: Int, b: Int, c: Int) =
@@ -412,9 +412,9 @@ object Sorting {
var j = i
while (j > off && x(j-1) > x(j)) {
swap(j, j-1)
- j = j - 1
+ j -= 1
}
- i = i + 1
+ i += 1
}
} else {
// Choose a partition element, v
@@ -442,23 +442,23 @@ object Sorting {
while (b <= c && x(b) <= v) {
if (x(b) == v) {
swap(a, b)
- a = a + 1
+ a += 1
}
- b = b + 1
+ b += 1
}
while (c >= b && x(c) >= v) {
if (x(c) == v) {
swap(c, d)
- d = d - 1
+ d -= 1
}
- c = c - 1
+ c -= 1
}
if (b > c) {
done = true
} else {
swap(b, c)
- c = c - 1
- b = b + 1
+ c -= 1
+ b += 1
}
}
@@ -489,17 +489,17 @@ object Sorting {
while (k <= hi) {
if ((t_lo <= mid) && ((t_hi > hi) || (f(a(t_lo), a(t_hi))))) {
scratch(k) = a(t_lo)
- t_lo = t_lo + 1
+ t_lo += 1
} else {
scratch(k) = a(t_hi)
- t_hi = t_hi + 1
+ t_hi += 1
}
- k = k + 1
+ k += 1
}
k = lo
while (k <= hi) {
a(k) = scratch(k)
- k = k + 1
+ k += 1
}
}
}