Stewart Stremler wrote: > begin quoting Christopher Smith as of Sun, Oct 01, 2006 at 12:39:25AM -0700: > >> Stewart Stremler wrote: >> >>> Contrary users may do whatever they please; trying to get around a >>> contrary user only makes a language ugly. (For example, "const". Ugh.) >>> >>> It's not my desire to keep the user from ever doing something stupid; only >>> to keep the user from doing something stupid by accident. >>> >> These two statements don't seem to make sense. const doesn't stop you >> from doing anything (one can always perform a const cast), it just makes >> it hard to do something by accident. >> > > You can get around consts with enough work, yes, but you're not *supposed* > to be able to do so. I've been told (despite providing evidence to the > contrary) that you _can't_ get around const -- the compiler won't LET you. > And that's certainly the *intent*. > I'm having a hard time reconciling this with the facts. There is a specific cast operation for getting rid of const (const_cast<>). It's hard to imagine that the intent of that was anything other than giving a programmer a way to explicitly ignore const. You have to know what you are doing when you use it, but that's true of any "this is likely a stupid move so we're gonna make you be explicit about it" operation in a language.
const Foo *bar = blah(); Foo* non_const_bar = const_cast<Foo*>(bar); --Chris -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
