Re: GHashTable and const



On Thu, Jul 3, 2008 at 2:34 PM, Ross Burton <ross burtonini com> wrote:
> On Thu, 2008-07-03 at 14:21 +0300, Andrew W. Nosenko wrote:
>> On Thu, Jul 3, 2008 at 2:11 PM, Rui Tiago Cação Matos
>> <tiagomatos gmail com> wrote:
>> > On 03/07/2008, Alberto Mardegan <mardy users sourceforge net> wrote:
>> >> Hi, quick question: why do methods like
>> >>
>> >>  g_hash_table_size()
>> >>  g_hash_table_lookup()
>> >>
>> >>  don't accept a "_const_ GHashTable *" as first parameter?
>> >
>> > Since GHashTable is an opaque data type you don't have to worry about it.
>>
>> Excuse me, but whether some type/structure is opaque or not have
>> nothing with constness.  It just irrelewant.  And yes, I'm also very
>> tired by hevy constless of Glib's API :-(
>
> Because const in C is crippled, unlike in C++ where its actually useful.
>

Soory, but you aren't right:
  1.  inability of GCC to hard optimization when pointers are involved
doesn't mean that another complers unable to do it also.
  2.  why you limit Glib's "C-binding" usage by C only?  I use it
inside C++ very often.
  3.  even if no one compiler under no one "compatible" language able
to use 'const' qualifer for pointer, it is very good even just for
humans as yet another hint/promise about interface/usage convetion.

and last (which is just because my personal taste and, therefore, may
be ignored):
  4.  proper usage of const would to reduce amount GCC warning about
casts away constness.

-- 
Andrew W. Nosenko <andrew w nosenko gmail com>


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