January 10, 2014 BitArray oddities | ||||
---|---|---|---|---|
| ||||
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? |
January 10, 2014 Re: BitArray oddities | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam S | On Friday, 10 January 2014 at 02:08:21 UTC, Adam S wrote: > Can anyone explain the reason for this setup? BitArray was mostly written back in the D1 days, before structs were allowed to have constructors. It got partially updated, but the majority of its code is still an old style. I recently talked about this on SO too: http://stackoverflow.com/questions/19679148/struct-constructor-or-init/19686732#19686732 |
Copyright © 1999-2021 by the D Language Foundation