Constants, Aliases

Sean Kelly sean at f4.ca
Thu Dec 14 08:44:40 PST 2006


Tomas Lindquist Olsen 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)
> 
> This actually feels more like a bug, but here's an example:
> 
> module noconst;
> import std.stdio;
> struct S {
>     float f;
> }
> const S s = {3.1415};
> void main() {
>     writefln(s.f);
>     s.f = 666;
>     writefln(s.f);
> }
> 
> (DMD.177)

On Windows, DMD doesn't put constants into ROM.  I'm not entirely sure 
why, but I suspect it may be that the OS doesn't support the idea?


Sean



More information about the Digitalmars-d mailing list