Jonathan M Davis, el 2 de noviembre a las 20:02 me escribiste: > 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.
I don't think it's a good idea to optimize out a struct member, as structs are often used to represent memory layouts when interacting with low level stuff (or not so low-level, like reading and writing a packet from the network). It seems pretty silly to have to avoid using immutable in those cases just to let the compiler "please, don't remove store from this struct". -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Y2K - what a disappointment... i had at least expected one nuclear plant to blow
