To dup or not to dup?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Mon Feb 26 07:31:22 PST 2007
Lionello Lunesu wrote:
> Frits van Bommel wrote:
>> Jürgen Herz wrote:
>>> BTW
>>> const char []a = "Test".dup;
>>> gives
>>> consttest.d(3): Error: cannot evaluate
>>> _adDupT(&_D12TypeInfo_G4a6__initZ,"Test") at compile time.
>>>
>>> What does in want to tell me?
>>
>> It wants to tell you that the result of '"Test".dup' cannot be
>> evaluated at compile time. In some cases, 'const' really _means_
>> constant in D, the value needs to be available at compile time (or
>> actually at link time in many cases).
>
> Strange, from the DMD changelog:
>
> * The .dup property is now allowed for compile time function execution.
>
> Why is it complaining for that .dup?
Because it's not constant enough to allow 'const', apparently. If you
remove the 'const' it works just fine.
More information about the Digitalmars-d
mailing list