Tango BitArray Initialization
Thomas Brix Larsen
brix at brix-verden.dk
Tue Feb 13 09:42:49 PST 2007
Sean Kelly wrote:
> Colin Huang wrote:
>> Sean Kelly Wrote:
>>> Oddly, I wasn't able to get static opAssign to work with this syntax.
>>> It seemed to want "BitArray = 0" rather than "BitArray b = 0". I've
>>> modified Tango's BitArray to support:
>>> BitArray b = [0,1,0,1];
>>> b = [1,0,1,0];
>>> which is consistent with how built-in arrays work.
>> Good work :)
> By the way, I think the above will break when implicit type conversions
> are added, because [0,1,0,1] is currently passed as a bool. I'll need
> to think about this a bit more, since [true,false,true,false] kind of
> stinks, as does accepting an array of ubyte or some such. This is an
> issue Walter will have to face as well since Phobos BitArray will have
> the same problem.
Can't you just make it a ubyte array, and throw an error if it isn't filled
with ones and zeros?
throw new Error("Stupid human! Bits are made up of ones and zeros!!");
More information about the Digitalmars-d-learn