Why D const is annoying

Kai Meyer kai at unixlords.com
Mon Dec 12 11:13:54 PST 2011


On 12/10/2011 03:52 AM, Timon Gehr wrote:
> On 12/10/2011 11:45 AM, bearophile wrote:
>> Timon Gehr:
>>
>>> Just slice the const array to get a range. The specialization for ranges
>>> does not have the bug.
>>>
>>> import std.algorithm;
>>> void main() {
>>> const arr = [1, 2, 3];
>>> reduce!"a*b"(arr[]); // It works.
>>> }
>>
>> Wasn't arr a range already?
>>
>> Bye,
>> bearophile
>
> No, popFront is mutating and const(int[]) cannot be mutated.

Seems to me like popFront isn't the right tool for the job.


More information about the Digitalmars-d mailing list