Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ??? and NotImplementedError because this ...

Added ??? and NotImplementedError because this seemed to be the
opinion of the majority on the "Adding ??? to Predef?" thread on
scala-internals. No review.
  • Loading branch information...
commit 497e6321a0aea209b679c428f1b76219d2920fd3 1 parent e98c864
@odersky odersky authored
View
19 src/library/scala/NotImplementedError.scala
@@ -0,0 +1,19 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+
+
+package scala
+
+/** Throwing this exception can be a temporary replacement for a method
+ * body that remains to be implemented. For instance, the exception is thrown by
+ * `Predef.???`.
+ */
+final class NotImplementedError(msg: String) extends Error(msg) {
+ def this() = this("an implementation is missing")
+}
View
5 src/library/scala/Predef.scala
@@ -222,6 +222,11 @@ object Predef extends LowPriorityImplicits {
}
implicit def any2Ensuring[A](x: A): Ensuring[A] = new Ensuring(x)
+ /** `???` can be used for marking methods that remain to be implemented.
+ * @throws A `NotImplementedError`
+ */
+ def ??? : Nothing = throw new NotImplementedError
+
// tupling ------------------------------------------------------------
type Pair[+A, +B] = Tuple2[A, B]

4 comments on commit 497e632

@KimStebel

Wouldn't def ???[A]:A be better, as that would make it easier to call methods on ???, for example ???[String].toLowerCase rather than ???.asInstanceOf[String].toLowerCase.

@paulp

I've never had a desire to call methods on ???, and I hope I never do. What is your use case for this?

@paulp

But in any case, ???[String] is no improvement on what you can already do, (??? : String).toLowerCase.

@KimStebel

Didn't think of (??? : String), so this would only be a marginal improvement. Use case would be that you already know parts of an implementation and just want to leave one part unimplemented. Doubt it would be used a lot.

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