Why we cannot use string in mixins?
mahdi via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 27 15:29:49 PST 2016
I read this criticism about D on Reddit and it claims that you
cannot use strings in mixins. Can you please elaborate about this
and the reason behind it?
QUOTE:
Look at strings: they are defined as immutable(char []).
"immutable" as in "you could put it in ROM", ... CTFE can't see
strings correctly (can't be determined at compile time). So
rather than fix the compiler so that strings can be used in
mixins in the way that people expect it to work even if that
means making them something other than immutable(char []), they
decided to start using enums where strings actually go.
Seriously: take the same code and replace 'string "foo"' with
'enum "foo"' and it starts to work!
END QUOTE
More information about the Digitalmars-d-learn
mailing list