diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Predef.scala | 2 | ||||
-rw-r--r-- | src/library/scala/Responder.scala | 19 | ||||
-rwxr-xr-x | src/library/scala/runtime/RichString.scala | 2 | ||||
-rwxr-xr-x | src/library/scala/runtime/StringAdd.scala | 14 |
4 files changed, 27 insertions, 10 deletions
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 0b18683135..b98696d5b4 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -416,6 +416,8 @@ object Predef { } } + implicit def any2stringadd(x: String) = new runtime.StringAdd(x) + implicit def string2seq(str: String): Seq[Char] = new Seq[Char] { def length = str.length() def elements = Iterator.fromString(str) diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index 8d294e95ea..7bd4967059 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -8,7 +8,7 @@ object Responder { /** creates a responder that answer continuations with the constant a */ def constant[a](x: a) = new Responder[a] { - def foreach(k: a => unit) = k(x) + def respond(k: a => unit) = k(x) } /** executes x and returns true, useful as syntactic convenience in @@ -42,22 +42,23 @@ object Responder { */ abstract class Responder[+a] { - def foreach(k: a => unit): unit + def respond(k: a => unit): unit + + def foreach(k: a => unit): unit = respond(k) def map[b](f: a => b) = new Responder[b] { - def foreach(k: b => unit): unit = - Responder.this.foreach(x => k(f(x))) + def respond(k: b => unit): unit = + Responder.this.respond(x => k(f(x))) } def flatMap[b](f: a => Responder[b]) = new Responder[b] { - def foreach(k: b => unit): unit = - Responder.this.foreach(x => f(x).foreach(k)) + def respond(k: b => unit): unit = + Responder.this.respond(x => f(x).respond(k)) } def filter(p: a => boolean) = new Responder[a] { - def foreach(k: a => unit): unit = - Responder.this.foreach(x => if (p(x)) k(x) else ()) + def respond(k: a => unit): unit = + Responder.this.respond(x => if (p(x)) k(x) else ()) } - } diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 44b66ce540..c1413997ce 100755 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: RichInt.scala 7771 2006-06-12 13:22:39Z dubochet $ +// $Id: RichString.scala 7771 2006-06-12 13:22:39Z dubochet $ package scala.runtime final class RichString(s: String) { diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala new file mode 100755 index 0000000000..d4f769c32e --- /dev/null +++ b/src/library/scala/runtime/StringAdd.scala @@ -0,0 +1,14 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: StringAdd.scala 7771 2006-06-12 13:22:39Z dubochet $ +package scala.runtime + +final class StringAdd(self: Any) { + def +(other: String) = self.toString + other +} |