Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-29 Thread Tim Peierls
On Fri, Mar 29, 2013 at 10:53 AM, Doug Lea wrote: > But really, the painfulness quotient is equally important. > We'd need to create immutableEnumSet class, and another class > that can arbitrarily extend the Spliterator's enums with > other control flags, all for the sake of arriving at an API >

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-29 Thread Joshua Bloch
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 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

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

2013-03-29 Thread Tim Peierls
I can't find a discussion of why Spliterator flags are ints rather than enum. The only thing coming close is this months-old update from Brian: *Sept 25, 2012 - Oct 24, 2012* > *... > **Stream flags improvements (Paul). *Added an "encounter order" flag. > Define flags with an enum. Make flags into

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-29 Thread Joshua Bloch
Doug, On Thu, Mar 28, 2013 at 12:06 PM, Doug Lea wrote: > On 03/28/13 14:52, Joshua Bloch wrote: > >> Doug, >> >> I don't get it. You can set and unset flags on your own EnumSet. Why >> isn't that >> sufficient? >> > > There are a lot of problems. First, even > though most spliterators will ret

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-29 Thread Doug Lea
On 03/28/13 15:14, Joshua Bloch wrote: Sounds like a perfect opportunity to put in immutableEnumSet, which is trivial to implement and generally useful. Alternatively, don't share, and see if the performance it good enough. (I suspect it will be.) Did you think that I of all people would I pa

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-29 Thread Paul Sandoz
On Mar 29, 2013, at 5:39 AM, Paul Benedict wrote: > I think the use of EnumSet in a public API is superior to bit flags. > Worrying about the number of bytes here is not important since they will > all end up being garbage collected when the stream processing ends. > I worry. We need to reduce

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-28 Thread Paul Benedict
I think the use of EnumSet in a public API is superior to bit flags. Worrying about the number of bytes here is not important since they will all end up being garbage collected when the stream processing ends. On Thu, Mar 28, 2013 at 6:56 PM, Vitaly Davidovich wrote: > Enum and EnumSet *are* goo

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-28 Thread Vitaly Davidovich
Enum and EnumSet *are* good, but the problem is the overhead of representation. If all you want is 32 bits to play with, you pay exactly 4 bytes in price if using int. With EnumSet, you pay object/heap overhead - on x64, 4 bytes vs 24; you pay GC price if you have lots of objects with embedded En

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-28 Thread Doug Lea
On 03/28/13 14:52, Joshua Bloch wrote: Doug, I don't get it. You can set and unset flags on your own EnumSet. Why isn't that sufficient? There are a lot of problems. First, even though most spliterators will return the same set of characteristics each time, you can't just create one static on

Re: Spliterator flags as enum (was Initial java.util.Spliterator putback)

2013-03-28 Thread Doug Lea
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