This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Putting ??? to work

6 replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

% scala
Welcome to Scala version 2.10.0.r25823-b20111011192940 (Java
HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class Bippy extends java.util.Collection[Int]
:7: error: class Bippy is missing 13 methods:
As seen from class Bippy, the missing method signatures are as follows.
(For convenience, these are usable as stub implementations.)

def add(x$1: Int): Boolean = ???
def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
def clear(): Unit = ???
def contains(x$1: Any): Boolean = ???
def containsAll(x$1: java.util.Collection[_]): Boolean = ???
def isEmpty(): Boolean = ???
def iterator(): java.util.Iterator[Int] = ???
def remove(x$1: Any): Boolean = ???
def removeAll(x$1: java.util.Collection[_]): Boolean = ???
def retainAll(x$1: java.util.Collection[_]): Boolean = ???
def size(): Int = ???
def toArray(): Array[Object] = ???
def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???

class Bippy extends java.util.Collection[Int]
^

scala> :paste
// Entering paste mode (ctrl-D to finish)

class Bippy extends java.util.Collection[Int] {
def add(x$1: Int): Boolean = ???
def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
def clear(): Unit = ???
def contains(x$1: Any): Boolean = ???
def containsAll(x$1: java.util.Collection[_]): Boolean = ???
def isEmpty(): Boolean = ???
def iterator(): java.util.Iterator[Int] = ???
def remove(x$1: Any): Boolean = ???
def removeAll(x$1: java.util.Collection[_]): Boolean = ???
def retainAll(x$1: java.util.Collection[_]): Boolean = ???
def size(): Int = ???
def toArray(): Array[Object] = ???
def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
}

// Exiting paste mode, now interpreting.

defined class Bippy

scala> new Bippy
res0: Bippy = Bippy@76e86c03

f.esser
Joined: 2009-11-23,
User offline. Last seen 42 years 45 weeks ago.
Re: Putting ??? to work
What about an internal delegation using a scala mutable collection,but I think it is not what you are asking for.

best regardsesser

2011/10/12 Paul Phillips <paulp [at] improving [dot] org>
% scala
Welcome to Scala version 2.10.0.r25823-b20111011192940 (Java
HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class Bippy extends java.util.Collection[Int]
<console>:7: error: class Bippy is missing 13 methods:
As seen from class Bippy, the missing method signatures are as follows.
(For convenience, these are usable as stub implementations.)

 def add(x$1: Int): Boolean = ???
 def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
 def clear(): Unit = ???
 def contains(x$1: Any): Boolean = ???
 def containsAll(x$1: java.util.Collection[_]): Boolean = ???
 def isEmpty(): Boolean = ???
 def iterator(): java.util.Iterator[Int] = ???
 def remove(x$1: Any): Boolean = ???
 def removeAll(x$1: java.util.Collection[_]): Boolean = ???
 def retainAll(x$1: java.util.Collection[_]): Boolean = ???
 def size(): Int = ???
 def toArray(): Array[Object] = ???
 def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???

      class Bippy extends java.util.Collection[Int]
            ^

scala> :paste
// Entering paste mode (ctrl-D to finish)

class Bippy extends java.util.Collection[Int] {
 def add(x$1: Int): Boolean = ???
 def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
 def clear(): Unit = ???
 def contains(x$1: Any): Boolean = ???
 def containsAll(x$1: java.util.Collection[_]): Boolean = ???
 def isEmpty(): Boolean = ???
 def iterator(): java.util.Iterator[Int] = ???
 def remove(x$1: Any): Boolean = ???
 def removeAll(x$1: java.util.Collection[_]): Boolean = ???
 def retainAll(x$1: java.util.Collection[_]): Boolean = ???
 def size(): Int = ???
 def toArray(): Array[Object] = ???
 def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
}

// Exiting paste mode, now interpreting.

defined class Bippy

scala> new Bippy
res0: Bippy = Bippy@76e86c03



Tiark Rompf
Joined: 2009-02-18,
User offline. Last seen 42 years 45 weeks ago.
Re: Putting ??? to work

Sweet! The Eclipse plugin should provide this as 'Quick Fix', too.
- Tiark

On Oct 12, 2011, at 4:39 AM, Paul Phillips wrote:

> % scala
> Welcome to Scala version 2.10.0.r25823-b20111011192940 (Java
> HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> class Bippy extends java.util.Collection[Int]
> :7: error: class Bippy is missing 13 methods:
> As seen from class Bippy, the missing method signatures are as follows.
> (For convenience, these are usable as stub implementations.)
>
> def add(x$1: Int): Boolean = ???
> def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
> def clear(): Unit = ???
> def contains(x$1: Any): Boolean = ???
> def containsAll(x$1: java.util.Collection[_]): Boolean = ???
> def isEmpty(): Boolean = ???
> def iterator(): java.util.Iterator[Int] = ???
> def remove(x$1: Any): Boolean = ???
> def removeAll(x$1: java.util.Collection[_]): Boolean = ???
> def retainAll(x$1: java.util.Collection[_]): Boolean = ???
> def size(): Int = ???
> def toArray(): Array[Object] = ???
> def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
>
> class Bippy extends java.util.Collection[Int]
> ^
>
> scala> :paste
> // Entering paste mode (ctrl-D to finish)
>
> class Bippy extends java.util.Collection[Int] {
> def add(x$1: Int): Boolean = ???
> def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
> def clear(): Unit = ???
> def contains(x$1: Any): Boolean = ???
> def containsAll(x$1: java.util.Collection[_]): Boolean = ???
> def isEmpty(): Boolean = ???
> def iterator(): java.util.Iterator[Int] = ???
> def remove(x$1: Any): Boolean = ???
> def removeAll(x$1: java.util.Collection[_]): Boolean = ???
> def retainAll(x$1: java.util.Collection[_]): Boolean = ???
> def size(): Int = ???
> def toArray(): Array[Object] = ???
> def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
> }
>
> // Exiting paste mode, now interpreting.
>
> defined class Bippy
>
> scala> new Bippy
> res0: Bippy = Bippy@76e86c03

Rodrigo Cano
Joined: 2009-03-22,
User offline. Last seen 42 years 45 weeks ago.
Re: Putting ??? to work
I've been asking for this a long time :)

On Wed, Oct 12, 2011 at 7:09 AM, Tiark Rompf <tiark [dot] rompf [at] epfl [dot] ch> wrote:
Sweet! The Eclipse plugin should provide this as 'Quick Fix', too.
- Tiark

On Oct 12, 2011, at 4:39 AM, Paul Phillips wrote:

> % scala
> Welcome to Scala version 2.10.0.r25823-b20111011192940 (Java
> HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> class Bippy extends java.util.Collection[Int]
> <console>:7: error: class Bippy is missing 13 methods:
> As seen from class Bippy, the missing method signatures are as follows.
> (For convenience, these are usable as stub implementations.)
>
>  def add(x$1: Int): Boolean = ???
>  def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
>  def clear(): Unit = ???
>  def contains(x$1: Any): Boolean = ???
>  def containsAll(x$1: java.util.Collection[_]): Boolean = ???
>  def isEmpty(): Boolean = ???
>  def iterator(): java.util.Iterator[Int] = ???
>  def remove(x$1: Any): Boolean = ???
>  def removeAll(x$1: java.util.Collection[_]): Boolean = ???
>  def retainAll(x$1: java.util.Collection[_]): Boolean = ???
>  def size(): Int = ???
>  def toArray(): Array[Object] = ???
>  def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
>
>       class Bippy extends java.util.Collection[Int]
>             ^
>
> scala> :paste
> // Entering paste mode (ctrl-D to finish)
>
> class Bippy extends java.util.Collection[Int] {
>  def add(x$1: Int): Boolean = ???
>  def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
>  def clear(): Unit = ???
>  def contains(x$1: Any): Boolean = ???
>  def containsAll(x$1: java.util.Collection[_]): Boolean = ???
>  def isEmpty(): Boolean = ???
>  def iterator(): java.util.Iterator[Int] = ???
>  def remove(x$1: Any): Boolean = ???
>  def removeAll(x$1: java.util.Collection[_]): Boolean = ???
>  def retainAll(x$1: java.util.Collection[_]): Boolean = ???
>  def size(): Int = ???
>  def toArray(): Array[Object] = ???
>  def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
> }
>
> // Exiting paste mode, now interpreting.
>
> defined class Bippy
>
> scala> new Bippy
> res0: Bippy = Bippy@76e86c03


dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Putting ??? to work

FTW!

On Tue, Oct 11, 2011 at 23:39, Paul Phillips wrote:
> % scala
> Welcome to Scala version 2.10.0.r25823-b20111011192940 (Java
> HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> class Bippy extends java.util.Collection[Int]
> :7: error: class Bippy is missing 13 methods:
> As seen from class Bippy, the missing method signatures are as follows.
> (For convenience, these are usable as stub implementations.)
>
>  def add(x$1: Int): Boolean = ???
>  def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
>  def clear(): Unit = ???
>  def contains(x$1: Any): Boolean = ???
>  def containsAll(x$1: java.util.Collection[_]): Boolean = ???
>  def isEmpty(): Boolean = ???
>  def iterator(): java.util.Iterator[Int] = ???
>  def remove(x$1: Any): Boolean = ???
>  def removeAll(x$1: java.util.Collection[_]): Boolean = ???
>  def retainAll(x$1: java.util.Collection[_]): Boolean = ???
>  def size(): Int = ???
>  def toArray(): Array[Object] = ???
>  def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
>
>       class Bippy extends java.util.Collection[Int]
>             ^
>
> scala> :paste
> // Entering paste mode (ctrl-D to finish)
>
> class Bippy extends java.util.Collection[Int] {
>  def add(x$1: Int): Boolean = ???
>  def addAll(x$1: java.util.Collection[_ <: Int]): Boolean = ???
>  def clear(): Unit = ???
>  def contains(x$1: Any): Boolean = ???
>  def containsAll(x$1: java.util.Collection[_]): Boolean = ???
>  def isEmpty(): Boolean = ???
>  def iterator(): java.util.Iterator[Int] = ???
>  def remove(x$1: Any): Boolean = ???
>  def removeAll(x$1: java.util.Collection[_]): Boolean = ???
>  def retainAll(x$1: java.util.Collection[_]): Boolean = ???
>  def size(): Int = ???
>  def toArray(): Array[Object] = ???
>  def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???
> }
>
> // Exiting paste mode, now interpreting.
>
> defined class Bippy
>
> scala> new Bippy
> res0: Bippy = Bippy@76e86c03
>

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: Putting ??? to work

Oh that is really cool.  If I can pick a nit, perhaps the generated argument names could be more humane, to make the copyable lines more immediately usable?

Anyway, nice work!

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Putting ??? to work

On Fri, Oct 14, 2011 at 5:56 AM, Ken Scambler wrote:
> Oh that is really cool.  If I can pick a nit, perhaps the generated argument
> names could be more humane, to make the copyable lines more immediately
> usable?

If the methods are from scala, you get the real names. Have to see
what can be done about java. I checked it in, here's what it looked
like by then.

/** As seen from class Dingus, the missing signatures are as follows.
* For convenience, these are usable as stub implementations.
*/
// Members declared in java.util.Collection
def add(x$1: String): Boolean = ???
def addAll(x$1: java.util.Collection[_ <: String]): Boolean = ???
def clear(): Unit = ???
def contains(x$1: Any): Boolean = ???
def containsAll(x$1: java.util.Collection[_]): Boolean = ???
def iterator(): java.util.Iterator[String] = ???
def remove(x$1: Any): Boolean = ???
def removeAll(x$1: java.util.Collection[_]): Boolean = ???
def retainAll(x$1: java.util.Collection[_]): Boolean = ???
def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ???

// Members declared in scala.collection.GenTraversableOnce
def isTraversableAgain: Boolean = ???
def toIterator: Iterator[(Set[Int], String)] = ???
def toStream: Stream[(Set[Int], String)] = ???

// Members declared in scala.math.Ordering
def compare(x: List[Int],y: List[Int]): Int = ???

// Members declared in scala.collection.TraversableOnce
def copyToArray[B >: (Set[Int], String)](xs: Array[B],start:
Int,len: Int): Unit = ???
def exists(p: ((Set[Int], String)) => Boolean): Boolean = ???
def find(p: ((Set[Int], String)) => Boolean): Option[(Set[Int], String)] = ???
def forall(p: ((Set[Int], String)) => Boolean): Boolean = ???
def foreach[U](f: ((Set[Int], String)) => U): Unit = ???
def hasDefiniteSize: Boolean = ???
def isEmpty: Boolean = ???
def seq: scala.collection.TraversableOnce[(Set[Int], String)] = ???
def toTraversable: Traversable[(Set[Int], String)] = ???

class Dingus extends Bippy[String, Set[Int], List[Int]]
^
four errors found

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland