November 23, 2005
Regan Heath wrote:

> On Tue, 22 Nov 2005 22:34:41 +0000 (UTC), <Munchgreeble@bigfoot.com> wrote:
> 
>> One thing I wasn't clear on though, how do these functions relate to bit  arrays?
>> Bit arrays seem like the obvious thing to use as arguments here - is it  possible
>> to use them instead?
> 
> 
> There are numerous posts on how bit arrays in D work, it seems people have  a love/hate relationship with them, try a search you'll see what I mean.

Thanks - a quick search for "bit array" was very informative. Actually I have to say that the archives are a mine of information. Everybody here in the newsgroup is so helpful and actually seems to dish out useful stuff. What a great place to be =)

> 
>> bit[32] bits;
>> bit[32] moreBits;
>> :
>> blah;
>> :
>> bits = bits ^ moreBits;
> 
> 
> I believe that once we get array operations the line above will be  possible.

Ah yes - OK. Array operations sound great =) What I'm wondering is will the compiler (be able to) optimise such operations on bit arrays so that you don't end up with 32 separate XORs going on in the compiled code. Similarly, doing + on two bit arrays should just do a bitwise OR on each of the elements and multiply should turn into bitwise AND. I guess this is the kind of thing that's do-able?

Cheers

Munch
November 23, 2005
On Wed, 23 Nov 2005 13:34:00 +0000, Munchgreeble <"a"@b.com "munchgreeble xATx bigfoot xDOTx com"> wrote:
>>> bit[32] bits;
>>> bit[32] moreBits;
>>> :
>>> blah;
>>> :
>>> bits = bits ^ moreBits;
>>   I believe that once we get array operations the line above will be  possible.
>
> Ah yes - OK. Array operations sound great =) What I'm wondering is will the compiler (be able to) optimise such operations on bit arrays so that you don't end up with 32 separate XORs going on in the compiled code. Similarly, doing + on two bit arrays should just do a bitwise OR on each of the elements and multiply should turn into bitwise AND. I guess this is the kind of thing that's do-able?

I suspect so. In which case I think we just "wait and see". I don't think optimisations like those are high on the priority list, compared to other things. I suspect that they and things like them will eventually get done, if we give Walter the time and space to do them in.

Regan
December 04, 2005
Munchgreeble wrote:
> Wow, now that's what I call casting =) It would have taken me quite a long time to almost get to that stage, give up and post to the newsgroup, so thanks - much appreciated.
> 
> It's not pretty I'll grant you, but you can usually encapsulate that stuff and cover it with comments, so I'm happy - thanks.
> 
> One thing I'm not clear on - does the slicing cost anything at run time? I'm guessing not since all the limits are calculable at compile time?

I suppose it depends how good the optimizer is.  Might be worth compiling with -O and looking at the output.


Sean
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home