On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote:
On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo wrote:
Currently, BitArray is not usable at compile time, so you cannot do
```
enum e = BitArray([1, 1, 1, 0]);
```
This gives
/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(1190): Error: `bts` cannot be interpreted at compile time, because it has no available source code

IIUC, that is because `bts` comes from core.bitop but no source code is there. I am guessing these are filled in by compiler intrinsics or the like, and they are unavailable at CT, correct?

I suppose that alternative implementations of `btc`, `bts`, `btr`, `bsf` and `bt` could exist that do not use the runtime that could be used if(__ctfe) in the implementation of BitArray, that would make the above code work. Is this feasible? Is there precedent in phobos? Are there complications?

Thanks!

Oh that ... actually I can fix that with a small patch to dmd.

Tell me which version are you using and I'll make it for you.

Cheers,

Stefan

Thank you, Stefan. At the moment we are using latest stable dmd, v2.082.1. I expect to switch to ldc or gdc at a later time. I don't think we'll be patching the compiler, support in the mainline compilers would be much preferable. It is not a blocker either, we can wait as long as it takes and meanwhile use module level BitArrays like
```
immutable BitArray e;
static this()
{
    e = BitArray([1, 1, 1, 0]);
}
```

It just seemed like a fixable limitation to me, hence my question here. Shall we start with a feature request?

Bastiaan.
  • CT BitArray Bastiaan Veelo via Digitalmars-d-learn
    • Re: CT BitArray Stefan Koch via Digitalmars-d-learn
      • Re: CT BitArray Bastiaan Veelo via Digitalmars-d-learn
      • Re: CT BitArray Bastiaan Veelo via Digitalmars-d-learn

Reply via email to