Extended Type Design.
Don Clugston
dac at nospam.com.au
Tue Mar 20 03:45:03 PDT 2007
Frits van Bommel wrote:
> Don Clugston wrote:
>> But then this really surprises me:
>>
>>> final int a = 2;
>>>
>>> void f(final int b)
>>> {
>>> }
>>> The choice of "final" in the second case prevents f from changing its
>>> argument,
>> > and it's the free will choice of f's author. The "final" does not
>> > influence f's signature or how other people use it.
>> > It's just constraining f's implementation.
>>
>> because it seems that that we still have 'const' surprises for C++
>> refugees.
>
> I don't see how this would be a surprise for anyone coming from C++.
> This is exactly how 'const' works for value types, isn't it?
Yes. The point is that for some uses of C++ const, you have to use
'const', while for others you need to use 'final'. I feel that this
weakens the argument for using the word 'const' in the C++ sense. The
hypothetical C++ refugee is still going to have culture shock when using
D const.
More information about the Digitalmars-d
mailing list