-
Notifications
You must be signed in to change notification settings - Fork 72
Adapt the parallel-collections module to the new design #328
Comments
Here is one possible path to migrate the parallel-collections:
|
Looks good! Actually I don't think that
|
I don't think it should even be called an I don't think you need such a supertrait, though. Handling both regular and parallel collections generically is an anti-pattern. There are too many ways that an assumption of sequential access can seep into the code. It's fine to have methods with the same signatures, but I'd rather that they were unrelated in the hierarchy. At the very most, maybe they could both have a typeclass that abstracted the common methods. |
Just to clarify: |
Giving one data point: in the Scala.js linker we do use parallel collections for the parallel optimizer. However, we also support a sequential optimizer that does not depend on parallel collections, since our linker cross-compiles to JVM/JS, and on JS it cannot use parallel collections. To that end, we kind of wanted to use the generic aspect of interfaces for sequential and parallel collections. In practice, though, we ended up needing an ad hoc abstract interface with abstract types for the operations that we care about, and implement it separately in the sequential optimizer and the parallel optimizer. Concretely, this means that even the high amount of sharing in the Scala 2.8-2.12 collections is not enough for a real use case, and requires ad hoc infrastructure anyway. Having less than that is only going to make it worse. I would therefore recommend that sequential and parallel collections be completely separated in the new collections, without any common interface. |
I’m creating the issue here but it’s about the following module: https://github.com/scala/scala-parallel-collections
We might not have a
GenIterable
type in the standard-library, but for people willing to generically program against an arbitrary collection, whether it is parallel or sequential, we could add aGenIterable
type in thescala-parallel-collections
module, and create implicit conversions from the standard collections to this type.The text was updated successfully, but these errors were encountered: