compile-time variables?
Don Clugston
dac at nospam.com.au
Wed May 30 05:00:12 PDT 2007
David B. Held wrote:
> BCS wrote:
>> [...]
>> why is it just char[], why not T[] for any T that can be used by it's
>> self? I have some cases where I want to do that.
>
> I don't know the full story, but after looking through the front-end
> code, my guess is that it's just easier that way.
> That is, when
> checking to see whether a particular type can be a compile-time array,
> it's easier to check against one type than against a set of types, or
> detect a set of type properties. Also, since dynamic char[] already
> violates the purity of metaprogramming, I think that Walter didn't want
> to expand and encourage that without thinking very hard about it (it's
> easier to give people new features than to take them away).
>
> Dave
Nope. It's because D had built-in support for string literals from way
back (whereas array literals are very recent). Concatenation of string
literals was accidentally possible, and I showed that it could be used
to do some interesting metaprogramming. I explicitly asked for the other
char [] operations to be constant folded at compile time. See the change
log for around DMD 0.135-0.145 to see the history.
More information about the Digitalmars-d
mailing list