Constants, Aliases

Lutger lutger.blijdestijn at gmail.com
Thu Dec 14 04:03:51 PST 2006


Alexander Panek wrote:
> Lutger wrote:
>> Xinok wrote:
>>> The problem with the const keyword is it doesn't guarantee the 
>>> expression will
>>> be constant.
>>
>> It doesn't? How can you modify a const var then? (in D)
> 
> You can modify const variables that are not set directly at declaration 
> (write-once constants) just by getting their address and modifying them 
> through another variable/pointer.

Haha yes it works. Is that how it should be or is it a bug or compiler 
limitation? It looks whacky to me. You can only write a const once in a 
constructor or so says DMD, thus it seems like this subverts the system 
in more than one way. I can't imagine that ever being useful.



More information about the Digitalmars-d mailing list