CTFE, string mixins & code generation
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jan 24 20:09:19 UTC 2020
On Fri, Jan 24, 2020 at 08:26:50PM +0100, Jacob Carlborg via Digitalmars-d-learn wrote:
> On 2020-01-24 19:43, H. S. Teoh wrote:
>
> > (enums cannot take AA's or class objects as values, also, once
> > assigned they are immutable).
>
> AA enums work.
Ah you're right, it's statically-constructed runtime AA's that don't
work. Mea culpa.
> Class objects kind of work. One can use static const/immutable
> instead. The following snippet compiles:
>
> class A
> {
> int a = 3;
> }
>
> const bar = new A;
> enum a = bar.a;
[...]
Wow. I'm actually surprised that works! That's pretty cool.
T
--
Almost all proofs have bugs, but almost all theorems are true. -- Paul Pedersen
More information about the Digitalmars-d-learn
mailing list