Immutable fields
Jonathan M Davis
jmdavisProg at gmx.com
Tue Nov 2 20:02:23 PDT 2010
On Tuesday 02 November 2010 19:24:29 bearophile wrote:
> Jonathan M Davis:
> > Why would it really matter though?
>
> I guess you have not followed my link with more explanations, right? :-)
>
> Bye,
> bearophile
I don't really get what you're doing there or what the problem is. You cast one
struct to another struct and it retained the same value for x. That seems
logical enough. You're just viewing that chunk of memory as a new type. You
didn't actually change what's there. My first reaction to seeing that sort of
cast though is that it's a bad idea anyway, though I guess that whether an
immutable variable has storage could affect the result in such a case. Generally
though, I would have argued that if you weren't going to set the variable with
the constructor, it should probably be an enum anyway.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list