Re: GHashTable and const



BJörn Lindqvist wrote:
Yes, i'm aware of that. Const variables just seem to grow like
mushrooms around const-accepting functions and those inevitably cause
trouble. Inside the function with a const parameter, that parameter
also only has to be passed to const parameter functions. That is
another case where warnings has to be fixed with irritating casts.

Why would a function taking a const parameter be calling a function with the parameter that isn't defined to take a const?

It may seem like a mushroom to you - to me it seems like a mine field *not* to use const. All compile time checking has this issue - and all compile time checks provide value. Which is worse? To realize that your supposedly const function is calling a non-const and having the compiler tell you about it? Or to not realize that your supposedly read-only function is doing modifications?

I prefer to use const, because I value what it provides. That it's imperfect is not a reason to avoid it.

The main issue with glib, though, is history. Most of the programming world is happy with using const, so I don't buy that the glib developers are smarter in their choice not to. The choice was wrong. But, it's water under the bridge. Life goes on. The question is now whether it's worth it to change - and I suspect the answer is no.

Cheers,
mark

--
Mark Mielke <mark mielke cc>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]