Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue.enqueue(iter: Iterable[B]) is never called #10137

Closed
scabug opened this issue Jan 7, 2017 · 8 comments
Closed

Queue.enqueue(iter: Iterable[B]) is never called #10137

scabug opened this issue Jan 7, 2017 · 8 comments

Comments

@scabug
Copy link

scabug commented Jan 7, 2017

Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> import collection.immutable.Queue
import collection.immutable.Queue

scala> Queue("foo")
res0: scala.collection.immutable.Queue[String] = Queue(foo)

scala> res0.enqueue(Iterable("bar", "baz"))
res1: scala.collection.immutable.Queue[Object] = Queue(foo, List(bar, baz))

The expected result is Queue("foo", "bar", "baz")

@scabug
Copy link
Author

scabug commented Jan 7, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10137?orig=1
Reporter: @Atry
Affected Versions: 2.12.1

@scabug
Copy link
Author

scabug commented Jan 10, 2017

@SethTisue said:
The other queue classes have def enqueue(elems: A*), so it looks to me like the method you're using here should be deprecated and removed, and the API brought in line with the other queue classes.

@scabug
Copy link
Author

scabug commented Jan 10, 2017

@som-snytt said (edited on Jan 10, 2017 5:57:20 AM UTC):
The expected enqueue takes an immutable.Iterable. Probably that's just a mistake, since the API (as + method) predates the introduction of immutable.Iterable with 2.8 collections. (It used to be scala.Iterable.)

scala> import collection.immutable.Queue
import collection.immutable.Queue

scala> Queue.empty[String].enqueue(collection.Iterable("bar","baz"))
res0: scala.collection.immutable.Queue[Object] = Queue(List(bar, baz))

scala> Queue.empty[String].enqueue(collection.immutable.Iterable("bar","baz"))
res1: scala.collection.immutable.Queue[String] = Queue(bar, baz)

@scabug
Copy link
Author

scabug commented Jan 10, 2017

@som-snytt said:
scala/scala#5638

@scabug
Copy link
Author

scabug commented Feb 11, 2017

@SethTisue said:
PR was merged, but leaving the ticket open since post-strawman we could make this more uniform.

@lrytz
Copy link
Member

lrytz commented Apr 23, 2018

@SethTisue what's the action item here?

@SethTisue SethTisue modified the milestones: 2.13.0-M4, 2.13.0-M5 May 14, 2018
@szeiger
Copy link
Member

szeiger commented May 30, 2018

mutable:

  def enqueue(elem: A): this.type
  def enqueue(elem1: A, elem2: A, elems: A*): this.type
  def enqueueAll(elems: scala.collection.IterableOnce[A]): this.type

immutable:

  def enqueue[B >: A](elem: B): Queue[B]
  def enqueue[B >: A](iter: scala.collection.Iterable[B])

I assume this is the non-uniformity to which Seth was referring earlier. We should deprecate the immutable enqueue(Iterable) and call it enqueueAll.

@som-snytt
Copy link

Cleaning up old branches, I found one with just the deprecation.

+  @deprecated("use ++ instead; this method will be removed", since = "2.12.2")
   def enqueue[B >: A](iter: Iterable[B]) =

redraw-dawn added a commit to redraw-dawn/scalaz-ioqueue that referenced this issue Oct 16, 2018
redraw-dawn added a commit to redraw-dawn/scalaz-ioqueue that referenced this issue Oct 16, 2018
redraw-dawn added a commit to redraw-dawn/scalaz-ioqueue that referenced this issue Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants