D const design rationale
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Jun 22 08:00:14 PDT 2007
Leandro Lucarella wrote:
> Walter Bright, el 22 de junio a las 01:07 me escribiste:
>> Sean Kelly wrote:
>>> Walter Bright wrote:
>>>> http://www.digitalmars.com/d/const.html
>>> So in short, 'const' protects data and 'final' freezes references. How do these two apply to an int declaration?
>>> const final int x = 5;
>>> Is either a compiler error? are they synonyms in this case?
>> It's not an error, it's just redundant.
>
> Shouldn't be better to be an error? So it's more clear that final makes
> sense only for reference types.
Allowing it allows cleaner generic code, otherwise templates would often
have to check whether parameters were value or reference types.
More information about the Digitalmars-d
mailing list