Into (original) (raw)

Brian Goetz brian.goetz at oracle.com
Sat Dec 22 14:15:37 PST 2012


For more functional/fluent/streamy usages, you'd like to enforce that any into-ish method creates a fresh instance and that construction cannot interfere with anything else.

+1. (This was my point #1 from the original note.)

So why not treat these as factories in existing catgories: toCollection(), toList(), toRandomAccessList() toSet(), toNavigableSet(); plus grouping versions toMap(keyfn, ...), toNavigableMap(keyFn, ...);

I like the convenience of these -- they meet the needs of many users without forcing people to learn about the tabulators framework (or whatever we call it). And also the flexibility of being able to provide better implementations over time. But I prefer they be sugar on top of something more general. So let's not let the surface simplicity of the simple case stop us from from addressing the general case.

(One thing I don't love is that they bring List/Map back into the API -- after all the work we did in groupBy to move it out. But this is more superficial than what groupBy/reduceBy did, so I'm probably OK with this -- especially if they are just sugar.)

The implementation can also take advantage of the fact that some collections (especially ArrayList) support fast parallel insertion upon creation but not once published.

Though unfortunately relies on implementation details rather than the spec for ArrayList.



More information about the lambda-libs-spec-experts mailing list