Re: BitArray new design - slice problems

2013-01-19 Thread Dmitry Olshansky
19-Jan-2013 11:14, Era Scarecrow пишет: On Friday, 18 January 2013 at 16:42:04 UTC, Dmitry Olshansky wrote: Slices should have a pointer and length so they can check range (in debug builds), alternatively just a pointer to storage that nows the range. So write an alternate opIndex... I

Re: BitArray new design - slice problems

2013-01-18 Thread Dmitry Olshansky
18-Jan-2013 01:49, Era Scarecrow пишет: On Thursday, 17 January 2013 at 19:36:34 UTC, Dmitry Olshansky wrote: I'm thinking that a opSlice of stack-allocated must be @system and a heap allocated can be @safe. That's just a small part of the problem. With the new design, 90% of it can be

Re: BitArray new design - slice problems

2013-01-17 Thread Dmitry Olshansky
17-Jan-2013 07:53, Era Scarecrow пишет: Well got a few curious problems. Slicing doesn't seem it wants to work as a separate type and can cause problems. Let's take an example. Say our slice is.. struct BitArraySlice { BitArray* ba; ulong start, end; } Now how much does

Re: BitArray new design - slice problems

2013-01-17 Thread Era Scarecrow
On Thursday, 17 January 2013 at 18:12:28 UTC, Dmitry Olshansky wrote: Well, the slice was invalidated by shrinking an array. I don't expect the below to work. It just seems like shrinking/expanding the array should still work, perhaps I'm thinking of them too much like a normal array slice.

Re: BitArray new design - slice problems

2013-01-17 Thread Dmitry Olshansky
17-Jan-2013 22:34, Era Scarecrow пишет: Thoughts? Feedback? I'm about ready to drop this and resume my previous version and enhance it with recent experiences. Feel free to do it how you see it. It's just that I think the semantics of the previous version can't be improved to a consistent

Re: BitArray new design - slice problems

2013-01-17 Thread H. S. Teoh
On Thu, Jan 17, 2013 at 11:36:33PM +0400, Dmitry Olshansky wrote: [...] I'm thinking that a opSlice of stack-allocated must be @system and a heap allocated can be @safe. [...] Related: http://d.puremagic.com/issues/show_bug.cgi?id=8838 T -- Who told you to swim in Crocodile Lake without

Re: BitArray new design - slice problems

2013-01-17 Thread Era Scarecrow
On Thursday, 17 January 2013 at 19:36:34 UTC, Dmitry Olshansky wrote: I'm thinking that a opSlice of stack-allocated must be @system and a heap allocated can be @safe. That's just a small part of the problem. With the new design, 90% of it can be safe; Just the actual slice buffer when you

BitArray new design - slice problems

2013-01-16 Thread Era Scarecrow
Well got a few curious problems. Slicing doesn't seem it wants to work as a separate type and can cause problems. Let's take an example. Say our slice is.. struct BitArraySlice { BitArray* ba; ulong start, end; } Now how much does it depend on the bitarray that it's pointing