Constants, Aliases
Tomas Lindquist Olsen
tomas at famolsen.dk
Thu Dec 14 04:00:49 PST 2006
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)
More information about the Digitalmars-d
mailing list