Constants, Aliases

Hasan Aljudy hasan.aljudy at gmail.com
Thu Dec 14 04:30:07 PST 2006



Lutger wrote:
> 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.

Why not?
It's useful when you work with sane programmers.

After all, with pointers and asm, there's no limit to how many things 
you can mess.



More information about the Digitalmars-d mailing list