Repository navigation
Conversation
mutable.ArrayDeque into mutable.Buffermutable.ArrayDeque into mutable.Buffer on the JVM
9b303aa to
b173a61
Compare
|
the community build failure is benign and expected given the nature of the change [123-3] X test.pprint.HorizontalTests.Horizontal.collections.Buffer 6ms
[123-3] utest.AssertionError: expected.map(_.trim).contains(pprinted)
[123-3] expected: Seq[String] = ArraySeq(ArrayBuffer("omg", "wtf", "bbq"), WrappedArray("omg", "wtf", "bbq"))
[123-3] pprinted: String = ArrayDeque("omg", "wtf", "bbq")
[123-3] utest.asserts.Asserts$.assertImpl(Asserts.scala:30)
[123-3] test.pprint.Check.apply$$anonfun$1(Check.scala:22)
[123-3] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[123-3] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[123-3] scala.collection.immutable.List.foreach(List.scala:327)
[123-3] test.pprint.Check.apply(Check.scala:19)
[123-3] test.pprint.HorizontalTests$.$init$$$anonfun$1$$anonfun$1$$anonfun$3$$anonfun$7(HorizontalTests.scala:115) |
Keeping complexity guarantees in sync between platforms is more important than keeping better constant factors. If we're going to improve complexity guarantees in the JVM, we must also change the JS version. |
50b1a25 to
1e79afa
Compare
|
I have updated the Scala.js implementation as well which previously used The mima changes should go away once we tweak mima to allow standard library evolution |
|
@lihaoyi this might be worth a rebase, feature freeze has been lifted on |
|
@Gedochao I have rebased it and it should be ready for review I think |
I guess we'd need an adjustment in |
|
@Gedochao yeah that's an expected change and I can update the pprint test suite if necessary |
|
Please do, we need the CI green, I guess. |
Forward compatibility for scala/scala3#25034
|
@Gedochao community build should be fixed by com-lihaoyi/PPrint#166 |
| @@ -0,0 +1,178 @@ | |||
| // Test for new ArrayDeque-style APIs on Buffer | |||
There was a problem hiding this comment.
It should have been a JUnit test in library/test/scala/collection/* - it might not have been present when PR was originally drafted, but that's the correct place to put standard library unit tests
| @@ -0,0 +1,12 @@ | |||
| testBufferUsesArrayDeque passed | |||
There was a problem hiding this comment.
Should be removed, .check files used to see expected output, not the progress of executing of test. Redundant when converting to dedicated unit test in stdlib project
We also require it to be mentioned on the contributors forum for people to raise potential issues with the proposal. |
|
These new methods on |
|
@SethTisue I want these added to buffer because it is in many ways the "default" mutable sequence constructor. |
|
We discussed it during meeting today I the biggest problem we saw is that it's very much disjoint from other collections. Maybe some of these method actually correspond to existing ones? Or at least we should follow similar conventions instead of having completely new names. ArrayDEqueue is itself an outlier in the collections. |
|
sorry, I should really have commented on the forum thread instead. I will comment there. |
|
@tgodzik what's so disjoint about |
|
@tgodzik @SethTisue well the discussion has had enough time on the forum (and i added a summary post this morning), so is it time to consider at core? |
|
As I wrote on the forum thread, core briefly discussed and broadly approves, but core hasn't necessarily studied all the details, e.g. naming of individual methods, and the requests for improved documentation that came up on the forum. So Jamie, if you and Haoyi are able to agree on and finalize those details, then I expect we'll be good. Marking as draft for now. |
|
@bishabosha anything we need to do here? It feels like the discussion did not result in any requested changes |
|
Also feel free to just patch the PR yourself, if you have straightforward changes no need to go through me if you know what you want |
|
@lihaoyi im just starting a vacation until August 16 so may be a bit slow |
|
@bishabosha this has been dragging on for close to a year now without any changes or updates, should I just close it? |
|
I'm in favour of the change, so i'll put some time toward it tomorrow |
c2bf6b8 to
64ac064
Compare
64ac064 to
1b68798
Compare
|
I added documentation per method, and now on ArrayBuffer and ListBuffer the cost of the default implementation is minimised. |
|
We discussed this today at the core meeting and this has green light. We just need to have it reviewed and the community build issue investigated. |
Co-authored-by: Jamie Thompson <bishbashboshjt@gmail.com> Co-authored-by: Li Haoyi <haoyi.sg@gmail.com>
Includes com-lihaoyi/PPrint#166, which accepts ArrayDeque as a Buffer.
1b68798 to
7a62a86
Compare
|
So the pprint had a test suite that checked the
|
As discussed in https://contributors.scala-lang.org/t/standard-library-now-open-for-improvements-and-suggestions/7337/62:
This PR adds the following convenience methods to
mutable.BufferThis PR basically swaps out
ArrayBufferin theBufferfactory objects withArrayDeque, and copies the uniqueArrayDequeconvenience methods over while forwarding them to the existing methods likeBuffer#remove. You could actually already do all these workflows withBufferalready, just that the API sucked (e.g.buffer.remove(buffer.length - 1)) and the asymptotic complexity of some operations sucked (e.g.buffer.remove(0)).This PR solves both those problems, so after this for most intents and purposes people reaching for the obvious thing
mutable.Buffer()will generally get everything they need without needing to separately reach formutable.ArrayDeque. There is still some im-precision in the types, since technically aBuffercould be aListBufferor some other weird data structure, but that's no worse than where we are today so it's still a strict improvementRegarding compatibility, we're only adding things to the API, which should be backwards binary and source compatible. And the change from
ArrayBuffertoArrayDequeonly improve the asymptotic complexity of some operations while leaving others unchangedI have updated the Scala.js implementation as well which previously used
js.WrappedArrayto also useArrayDeque