Spliterator flags as enum (was Initial java.util.Spliterator putback) (original) (raw)

Joshua Bloch josh at bloch.us
Thu Mar 28 18:52:29 UTC 2013


Doug,

I don't get it. You can set and unset flags on your own EnumSet. Why isn't that sufficient?

Josh

On Thu, Mar 28, 2013 at 11:45 AM, Doug Lea <dl at cs.oswego.edu> wrote:

On 03/28/13 13:18, Tim Peierls wrote:

I can't find a discussion of why Spliterator flags are ints rather than enum.

We started out with enums on (my) initial Spliterator side vs control flags internal to streams. The we had to somehow mesh these to work together. On the stream side, you need to set and unset various bits across stages. Clearly you can't do that to someone's EnumSet -- they will not expect you to modify it, but enforcing this makes it both unwieldy and sleaze-inducing (we'd have to grab underlying representation from EnumSet). Another way of saying this is that we needed an efficient propagate-by-value small-N bit set mechanism, and the only candidate was the traditional one. This amounts to the same reason that nio "interest" flags are done the same way. -Doug



More information about the core-libs-dev mailing list