Skip to content

Commit

Permalink
Added ??? and NotImplementedError because this ...
Browse files Browse the repository at this point in the history
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
odersky committed Oct 7, 2011
1 parent e98c864 commit 497e632
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/library/scala/NotImplementedError.scala
Original file line number Diff line number Diff line change
@@ -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")
}
5 changes: 5 additions & 0 deletions src/library/scala/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

4 comments on commit 497e632

@KimStebel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@paulp paulp commented on 497e632 Dec 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@paulp
Copy link
Contributor

@paulp paulp commented on 497e632 Dec 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@KimStebel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.