Jump to page: 1 2
Thread overview
[phobos] phobos commit, revision 1740
Jul 09, 2010
dsource.org
Jul 09, 2010
Jonathan M Davis
Jul 09, 2010
Jonathan M Davis
Jul 09, 2010
Sean Kelly
Jul 09, 2010
Sean Kelly
Jul 09, 2010
Jonathan M Davis
Jul 09, 2010
Walter Bright
Jul 09, 2010
Jonathan M Davis
July 08, 2010
phobos commit, revision 1740


user: andrei

msg:
Defined TotalContainer such that all member functions issue assert(0). That way it's easy to build new containers by copying and pasting TotalContainer. Also added specialization of Array for bool that stores one bit per element.

http://www.dsource.org/projects/phobos/changeset/1740

July 08, 2010
> Also added specialization of Array for bool that stores
> one bit per element.

_Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool> in C++ _precisely_ because of this optimization. I don't think that I've ever talked to anyone who thought that vector<bool> being special in that manner was a good thing. And because no one uses vector<bool> makes vector useless for bools. I have no problem whatsoever with a special version of Array which you can decide to use if you _want_ Array!bool to use only one bit per element, but I'd _hate_ to see that be the general case or for it happen to the programmer without requesting it. So, a separate BoolArray (or even better, BitArray) or some sort of version of Array that somehow allowed you to choose whether you wanted bools to be normal-sized or bit-sized would be fine with me, but _please_ don't make Array!bool contain anything other than normal bools by default.

- Jonathan M Davis
July 09, 2010
On 07/09/2010 12:25 AM, Jonathan M Davis wrote:
>> Also added specialization of Array for bool that stores one bit per element.
>
> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization. I don't think that I've ever talked to anyone who thought that vector<bool>  being special in that manner was a good thing.

I am well aware of vector<bool>'s problems and designed Array!bool very carefully to avoid each and all of them.

Andrei
July 08, 2010
On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:

>> Also added specialization of Array for bool that stores
>> one bit per element.
> 
> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool> in C++ _precisely_ because of this optimization.

Looks like this optimization is largely invisible to the user, unlike vector<bool>, and intended largely for space saving.  If you want a plain old BitArray there's one in std.bitmanip.
July 09, 2010
On 07/09/2010 01:28 AM, Sean Kelly wrote:
> On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:
>
>>> Also added specialization of Array for bool that stores one bit per element.
>>
>> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization.
>
> Looks like this optimization is largely invisible to the user, unlike vector<bool>, and intended largely for space saving.  If you want a plain old BitArray there's one in std.bitmanip.

Yah. The issues are subtle, I plan to write an entire article about them.

Andrei

P.S. Nice going on stackoverflow.com, Jonathan.
July 09, 2010
On Thursday 08 July 2010 23:17:22 Andrei Alexandrescu wrote:
> On 07/09/2010 12:25 AM, Jonathan M Davis wrote:
> >> Also added specialization of Array for bool that stores one bit per element.
> > 
> > _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization. I don't think that I've ever talked to anyone who thought that vector<bool>  being special in that manner was a good thing.
> 
> I am well aware of vector<bool>'s problems and designed Array!bool very carefully to avoid each and all of them.
> 
> Andrei
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

Well, I would have thought that you'd have been aware of the issue, but since I've never heard of anyone thinking that doing anything other than just making vector<bool> function like it would with vector<int> or vector<string> or whatever, I was very surprised to see that you would consider doing something similar with Array!bool. Now, if you're sure that you've managed to avoid the issues that exist with vector<bool>, then that's fine, but I'd hate for D to have the same problems with Array!bool that C++ has with vector<bool>.

- Jonathan M Davis
July 09, 2010
On Thursday 08 July 2010 23:48:06 Andrei Alexandrescu wrote:
> On 07/09/2010 01:28 AM, Sean Kelly wrote:
> > On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:
> >>> Also added specialization of Array for bool that stores one bit per element.
> >> 
> >> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization.
> > 
> > Looks like this optimization is largely invisible to the user, unlike vector<bool>, and intended largely for space saving.  If you want a plain old BitArray there's one in std.bitmanip.
> 
> Yah. The issues are subtle, I plan to write an entire article about them.

I'll definitely be looking forward to that article.

> 
> Andrei
> 
> P.S. Nice going on stackoverflow.com, Jonathan.

Thanks!

- Jonathan M Davis
July 09, 2010
Fortunately, we aren't bound by a standards body, so if there turn out to be problems we could just rip it out.

Sent from my iPhone

On Jul 9, 2010, at 12:02 AM, Jonathan M Davis <jmdavisprog at gmail.com> wrote:

> On Thursday 08 July 2010 23:17:22 Andrei Alexandrescu wrote:
>> On 07/09/2010 12:25 AM, Jonathan M Davis wrote:
>>>> Also added specialization of Array for bool that stores one bit per element.
>>> 
>>> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization. I don't think that I've ever talked to anyone who thought that vector<bool>  being special in that manner was a good thing.
>> 
>> I am well aware of vector<bool>'s problems and designed Array!bool very carefully to avoid each and all of them.
>> 
>> Andrei
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
> 
> Well, I would have thought that you'd have been aware of the issue, but since I've never heard of anyone thinking that doing anything other than just making vector<bool> function like it would with vector<int> or vector<string> or whatever, I was very surprised to see that you would consider doing something similar with Array!bool. Now, if you're sure that you've managed to avoid the issues that exist with vector<bool>, then that's fine, but I'd hate for D to have the same problems with Array!bool that C++ has with vector<bool>.
> 
> - Jonathan M Davis
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
July 09, 2010

Andrei Alexandrescu wrote:
> On 07/09/2010 01:28 AM, Sean Kelly wrote:
>> On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:
>>
>>>> Also added specialization of Array for bool that stores one bit per element.
>>>
>>> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization.
>>
>> Looks like this optimization is largely invisible to the user, unlike vector<bool>, and intended largely for space saving.  If you want a plain old BitArray there's one in std.bitmanip.
>
> Yah. The issues are subtle, I plan to write an entire article about them.
>

Yes, clearly there needs to be a hint in the documentation about this, otherwise everyone will just assume it is a clone of vector<bool>, problems and all.
July 09, 2010
On Friday, July 09, 2010 12:04:37 Walter Bright wrote:
> Andrei Alexandrescu wrote:
> > On 07/09/2010 01:28 AM, Sean Kelly wrote:
> >> On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:
> >>>> Also added specialization of Array for bool that stores one bit per element.
> >>> 
> >>> _Please_ tell me that's optional in some manner. I don't know _anyone_ who uses vector<bool>  in C++ _precisely_ because of this optimization.
> >> 
> >> Looks like this optimization is largely invisible to the user, unlike vector<bool>, and intended largely for space saving.  If you want a plain old BitArray there's one in std.bitmanip.
> > 
> > Yah. The issues are subtle, I plan to write an entire article about them.
> 
> Yes, clearly there needs to be a hint in the documentation about this,
> otherwise everyone will just assume it is a clone of vector<bool>,
> problems and all.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

Well, unless they actually look at the source code (and most wouldn't, I would think), then they wouldn't have a clue that Array!bool was special. So, I think that it's more likely that they'd think that Array!bool worked like Array!int, Array!string, etc. then for them to think that it works like vector<bool>. Still, I'd expect that most who figured out that it was doing something special with 1 bit per element would think that it was problematic like vector<bool>. But regardless, it would be good if it were made clear what Array!bool is doing and why it's not a problem like vector<bool> is.

- Jonathan M Davis
« First   ‹ Prev
1 2