Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
(Moved from: What have I missed?) If this is the wrong place to ask these questions I apologize, getting back into this takes some work. So I guess I need to ask: Should I try to resume work on the BitManip library? (So far it seems none of my code has been integrated to phobos)

Re: BitArray/BitFields - Review

2014-08-06 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 07, 2014 at 01:10:06AM +, Era Scarecrow via Digitalmars-d-learn wrote: (Moved from: What have I missed?) If this is the wrong place to ask these questions I apologize, getting back into this takes some work. Since this is about contributing to Phobos, probably a better

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 01:51:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Since this is about contributing to Phobos, probably a better place to ask is on the main D forum. Yeah posted in my 'what have i missed?' as well... Do you have a pull request? Which one is it?

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 02:04:13 UTC, Era Scarecrow wrote: On Thursday, 7 August 2014 at 01:51:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Do you have a pull request? Which one is it? https://github.com/rtcvb32/phobos/pull/1 From the looks of things it's 4 commits that are merged

Re: BitArray/BitFields - Review

2014-08-06 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 07, 2014 at 02:04:12AM +, Era Scarecrow via Digitalmars-d-learn wrote: On Thursday, 7 August 2014 at 01:51:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Since this is about contributing to Phobos, probably a better place to ask is on the main D forum. Yeah posted in my

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 02:12:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Hold on a sec... that's a pull for your own fork of Phobos. You need to submit a pull to the main Phobos repo in order to get it reviewed and merged. :-) Well, no wonder, your pull was submitted against

Re: BitArray/BitFields - Review

2012-07-31 Thread Don Clugston
On 29/07/12 23:36, bearophile wrote: Era Scarecrow: Another commonly needed operation is a very fast bit count. There are very refined algorithms to do this. Likely similar to the hamming weight table mentioned in TDPL. Combined with the canUseBulk I think I could make it fairly fast.

Re: BitArray/BitFields - Review

2012-07-29 Thread Dmitry Olshansky
On 29-Jul-12 03:16, Era Scarecrow wrote: On Saturday, 28 July 2012 at 23:02:17 UTC, Dmitry Olshansky wrote: On 29-Jul-12 02:31, Era Scarecrow wrote: On Saturday, 28 July 2012 at 22:19:05 UTC, Dmitry Olshansky wrote: Mhm? Not getting you it at all. What's locking it ? What's wrong with:

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 06:27:32 UTC, Dmitry Olshansky wrote: OK. Now back to the biggest question: Slices use references (sometimes) to previous bitarray. Since it's a slice (like an array) this could be expected. The sometimes part is not god enough! The problem is that small string

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 06:27:32 UTC, Dmitry Olshansky wrote: Thus BitArray either becomes value type (that may come as unexpected, see your option c/d). Or it becomes full reference type as in option a (though it sucks). Sorry but b is no go, as it makes code unpredictable I'd rather take

Re: BitArray/BitFields - Review

2012-07-29 Thread Dmitry Olshansky
On 29-Jul-12 12:55, Era Scarecrow wrote: On Sunday, 29 July 2012 at 06:27:32 UTC, Dmitry Olshansky wrote: Thus BitArray either becomes value type (that may come as unexpected, see your option c/d). Or it becomes full reference type as in option a (though it sucks). Sorry but b is no go, as it

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 09:03:08 UTC, Dmitry Olshansky wrote: On 29-Jul-12 12:55, Era Scarecrow wrote: Doing it this way the arguments being passed as reference slices would ensure unneeded copies wouldn't be made. On the other hand a smaller portion of the code would need to be updated.

Re: BitArray/BitFields - Review

2012-07-29 Thread Dmitry Olshansky
On 29-Jul-12 13:18, Era Scarecrow wrote: On Sunday, 29 July 2012 at 09:03:08 UTC, Dmitry Olshansky wrote: On 29-Jul-12 12:55, Era Scarecrow wrote: Doing it this way the arguments being passed as reference slices would ensure unneeded copies wouldn't be made. On the other hand a smaller portion

Re: BitArray/BitFields - Review

2012-07-29 Thread Dmitry Olshansky
On 29-Jul-12 14:28, Era Scarecrow wrote: On Sunday, 29 July 2012 at 09:30:06 UTC, Dmitry Olshansky wrote: I have simpler suggestion. Maybe doing it as 2 containers: BitSet is a plain value type with small array optimization (what you called BitArray in last 2 posts) and no slicing (only as

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 10:34:50 UTC, Dmitry Olshansky wrote: Might be a third option: A template struct that represents a BitArray type (with 90% of the code); you then insert a structure with key functions that would handle the value/reference duplication part. Sounds a lot like

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 09:30:06 UTC, Dmitry Olshansky wrote: I have simpler suggestion. Maybe doing it as 2 containers: BitSet is a plain value type with small array optimization (what you called BitArray in last 2 posts) and no slicing (only as opSlice() I.e. as a whole). Best used for

Re: BitArray/BitFields - Review

2012-07-29 Thread bearophile
Era Scarecrow: As you guess I have had to use many arrays of bits in my programs :-) 4124 - Set/reset all bits ie: BitArray ba = BitArray(100); ba[] = true; Others haven't been done yet. Among those 4124 suggestions the most important, and very simple to implement, are: - set n-th

Re: BitArray/BitFields - Review

2012-07-29 Thread Era Scarecrow
On Sunday, 29 July 2012 at 14:41:48 UTC, bearophile wrote: As you guess I have had to use many arrays of bits in my programs :-) I'll do what I can :) 4124 - Set/reset all bits ie: BitArray ba = BitArray(100); ba[] = true; Others haven't been done yet. Among those 4124 suggestions the

BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
BitFields: https://github.com/rtcvb32/phobos/commit/729c96e2f20ddd0c05a1afb488030b5c4db3e012 new BitArray Overhead functions/templates: https://github.com/rtcvb32/phobos/commit/55aaf82a39f3901f03f5f1ac26fd175c5b2cd167 BitArray:

Re: BitArray/BitFields - Review

2012-07-28 Thread Jonathan M Davis
On Saturday, July 28, 2012 22:41:48 Era Scarecrow wrote: 2) opCast disabled: Anyone using opCast their code will break, however depending on it's usage that may not be an issue. If anyone can recommend alternative opCast(s) that won't prevent normal use of casting, then they will be

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 00:41, Era Scarecrow wrote: BitFields: https://github.com/rtcvb32/phobos/commit/729c96e2f20ddd0c05a1afb488030b5c4db3e012 new BitArray Overhead functions/templates: https://github.com/rtcvb32/phobos/commit/55aaf82a39f3901f03f5f1ac26fd175c5b2cd167 BitArray:

Re: BitArray/BitFields - Review

2012-07-28 Thread Jonathan M Davis
On Sunday, July 29, 2012 00:58:59 Dmitry Olshansky wrote: My solution is make slices different type e.g. BitSlice. It's always reference to the original BitArray. Array itself still can be either compact or not. All operations with slice go to array (and still check if they can use

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 01:07, Jonathan M Davis wrote: On Sunday, July 29, 2012 00:58:59 Dmitry Olshansky wrote: My solution is make slices different type e.g. BitSlice. It's always reference to the original BitArray. Array itself still can be either compact or not. All operations with slice go to array

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 20:59:15 UTC, Dmitry Olshansky wrote: Great! But I strongly suggest to repost it in d.D newsgroup as it has wider audience and is more appropriate for reviews. I was thinking of not bothering Andrei or Walter while i fixed other issues on it before bringing more

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 21:07:31 UTC, Jonathan M Davis wrote: I would point out that while hasSlicing doesn't currently check for it, if opSlice doesn't return a type which is assignable to the original range, it won't work in a lot of Phobos functions. I keep meaning to bring that up for

Re: BitArray/BitFields - Review

2012-07-28 Thread Jonathan M Davis
On Sunday, July 29, 2012 01:19:49 Dmitry Olshansky wrote: On 29-Jul-12 01:07, Jonathan M Davis wrote: On Sunday, July 29, 2012 00:58:59 Dmitry Olshansky wrote: My solution is make slices different type e.g. BitSlice. It's always reference to the original BitArray. Array itself still can

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 01:20, Era Scarecrow wrote: On Saturday, 28 July 2012 at 20:59:15 UTC, Dmitry Olshansky wrote: Great! But I strongly suggest to repost it in d.D newsgroup as it has wider audience and is more appropriate for reviews. I was thinking of not bothering Andrei or Walter while i

Re: BitArray/BitFields - Review

2012-07-28 Thread Jonathan M Davis
On Saturday, July 28, 2012 23:23:30 Era Scarecrow wrote: On Saturday, 28 July 2012 at 21:07:31 UTC, Jonathan M Davis wrote: I would point out that while hasSlicing doesn't currently check for it, if opSlice doesn't return a type which is assignable to the original range, it won't work in a

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 21:30:21 UTC, Jonathan M Davis wrote: Well, it seems that my comment was somewhat misplaced in that BitArray isn't a range but a container. My comment was directed at opSlice on ranges. Container types should return whatever range type is appropriate. That will

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 21:39:56 UTC, Era Scarecrow wrote: BitArray (Ie const(int)) it's otherwise should not be My filter/formatter got me again... Honestly that doesn't add up to what I call an 'array'. It should look like an array, act like an array, and besides not being able to

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 01:39, Era Scarecrow wrote: On Saturday, 28 July 2012 at 21:30:21 UTC, Jonathan M Davis wrote: Well, it seems that my comment was somewhat misplaced in that BitArray isn't a range but a container. My comment was directed at opSlice on ranges. Container types should return whatever

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 21:49:45 UTC, Dmitry Olshansky wrote: On 29-Jul-12 01:39, Era Scarecrow wrote: An array suggests you can control the size of the array, however if you are forced to work in 32increments (or more if 64bit), that makes it highly hard to control without making it a

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 02:08, Era Scarecrow wrote: On Saturday, 28 July 2012 at 21:49:45 UTC, Dmitry Olshansky wrote: On 29-Jul-12 01:39, Era Scarecrow wrote: An array suggests you can control the size of the array, however if you are forced to work in 32increments (or more if 64bit), that makes it

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 22:19:05 UTC, Dmitry Olshansky wrote: Mhm? Not getting you it at all. What's locking it ? What's wrong with: struct BitArray { union { struct { size_t[] data; ulong length; //in bits //length in words would be just //

Re: BitArray/BitFields - Review

2012-07-28 Thread bearophile
Era Scarecrow: BitFields: I've concentrated on adding default values. Good, that's useful. Regarding BitArray I have written some ER: http://d.puremagic.com/issues/show_bug.cgi?id=4123 http://d.puremagic.com/issues/show_bug.cgi?id=4124 http://d.puremagic.com/issues/show_bug.cgi?id=4717

Re: BitArray/BitFields - Review

2012-07-28 Thread Dmitry Olshansky
On 29-Jul-12 02:31, Era Scarecrow wrote: On Saturday, 28 July 2012 at 22:19:05 UTC, Dmitry Olshansky wrote: Mhm? Not getting you it at all. What's locking it ? What's wrong with: struct BitArray { union { struct { size_t[] data; ulong length;//in bits //length in

Re: BitArray/BitFields - Review

2012-07-28 Thread Era Scarecrow
On Saturday, 28 July 2012 at 23:02:17 UTC, Dmitry Olshansky wrote: On 29-Jul-12 02:31, Era Scarecrow wrote: On Saturday, 28 July 2012 at 22:19:05 UTC, Dmitry Olshansky wrote: Mhm? Not getting you it at all. What's locking it ? What's wrong with: struct BitArray { union { struct {