BitArray oddities

Adam S longestpants at gmail.com
Thu Jan 9 18:08:20 PST 2014


Playing around with BitArray I encountered the seemingly strange 
interface of

-------
bool[] b = [0, 1, 0];

BitArray a;
a.init(b);
-------

Is there any reason 'init' is used rather than using a 
constructor?

--------
bool[] b = [0, 1, 0];

BitArray a = BitArray(b);
--------

Seems a bit clearer. Regardless, the current approach seems to 
create problems when used with std.parallelism. Specifically the 
following fails to compile:

--------
BitArray[] arr;
arr ~= BitArray();

taskPool.amap!((BitArray a) {/*do something*/})(arr);
--------
Fails with:
     Error: function std.bitmanip.BitArray.init (bool[] ba) is not 
callable using argument types ()

Can anyone explain the reason for this setup?


More information about the Digitalmars-d-learn mailing list