Head Const

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 17 09:25:40 PST 2016


On Tuesday, 16 February 2016 at 10:31:05 UTC, Guillaume Piolat 
wrote:
> On Tuesday, 16 February 2016 at 01:04:44 UTC, Walter Bright 
> wrote:
>>>> 2. supports single assignment style of programming, even if 
>>>> the data is
>>>> otherwise mutable
>>> Like 'final'?  We did get rid of that...
>>
>> Maybe we should resurrect it.
>
> I'm trying to say it politely.
> D2 const story is more complicated than its competitors.
>
> Both D1 "final" and C++ const always felt more useful and 
> practical to me that the whole D2 immutable/const/inout thing. 
> The current scheme seems to have marginal value in practice, 
> lots of complexity, and is harder to use well (Unqual, inout) 
> etc. Constructors can break it. I don't know why we should be 
> that happy about our constness, maybe someone can explain.

+1

It's weird because usually D prefers the practical solution over 
the ivory tower one. Nearly every time I end up using immutable 
or const for anything beyond say, a trivial function parameter, I 
always end up removing it.
My C++ code is often far, far more 'const correct' than my D code.


More information about the Digitalmars-d mailing list