Why D const is annoying
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Dec 10 11:11:58 PST 2011
On 12/10/11 5:10 AM, Mehrdad wrote:
> On 12/10/2011 3:08 AM, bearophile wrote:
>> Timon Gehr:
>>
>>> No, popFront is mutating and const(int[]) cannot be mutated.
>> So, is it impossible by design to iterate immutable collections?
>>
>> Bye,
>> bearophile
>
> I believe the answer is yes (although Timon would probably know better).
>
> That's one reason I believe const is broken...
That is incorrect (it's easy to design a range iterating over an
immutable collection, and in particular const(T)[] iterates a const T[]
no problem), but taking the time to vent about the annoyances you've
encountered is highly appreciated.
I suspect many people try D just like you do, with a few cool ideas (no
conservative "hello world" programs), see they don't work for obscure
reasons, go like "meh", and give up. So having such an experience
_documented_ is of great value.
I'm every bit as annoyed as you are about simple things not working with
qualifiers, and I have a few ideas on how to fix it. I should add that I
very strongly believe a problem with a workaround does not implicitly
cease being a problem.
Andrei
More information about the Digitalmars-d
mailing list