httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Finch <>
Subject Re: cvs commit: apache-2.0/src/lib/apr/lib apr_hash.c
Date Mon, 17 Jul 2000 18:16:31 GMT
Ben Laurie wrote:
>Greg Stein wrote:
>> [ and no, tracking const-ness would not be a good thing to add ]
>Why not?
>> Adding the "const" on the ap_hash_set() allows you to actually place const
>> data in there. Without the const, you get errors on the set() if you have
>> const data. But if the get() is non-const, then you can place it into const
>> or non-const pointers.
>Which means you can deconstify a const, accidentally. Which is why
>tracking constness _is_ a good thing. IMO.

I think that you are trying to do something that the language will not support.

I agree that it is a good idea to try to find as many errors at compile time
as possible, and constness and other type issues are a substantial part of
this, but in this situation the problem can only be solved by the sort of fully
polymorphic type system that C doesn't have. If you want Haskell you know where
to find it.

The *only* way to fix this problem in C is with code duplication for the const
and non-const cases. (In C++ the compiler can do this for you; I doubt the
implementation of templates is clever enough yet to avoid pointless code

307 wriggling grunion in your slipstream

View raw message