Re: GHashTable and const

2008-07-14 Thread Paul Smith
On Mon, 2008-07-14 at 23:52 +0300, Felipe Contreras wrote: > I don't get it, can you explain how exactly? The function prototypes will be different, so you won't be able to assign without casting, or else changing the type of thing holding the function pointer. ___

Re: GHashTable and const

2008-07-14 Thread Felipe Contreras
On Thu, Jul 10, 2008 at 7:00 PM, Andrew W. Nosenko <[EMAIL PROTECTED]> wrote: > On Thu, Jul 10, 2008 at 5:17 PM, Havoc Pennington <[EMAIL PROTECTED]> wrote: >> Hi, >> >> On Thu, Jul 10, 2008 at 6:10 AM, Andrew W. Nosenko >> <[EMAIL PROTECTED]> wrote: >>> Sorry for long delay, but could you please e

Re: GHashTable and const

2008-07-10 Thread Andrew W. Nosenko
On Thu, Jul 10, 2008 at 5:17 PM, Havoc Pennington <[EMAIL PROTECTED]> wrote: > Hi, > > On Thu, Jul 10, 2008 at 6:10 AM, Andrew W. Nosenko > <[EMAIL PROTECTED]> wrote: >> Sorry for long delay, but could you please explain, how changing from >>g_hash_table_size (GHashTable *hash_table); >> to >>

Re: GHashTable and const

2008-07-10 Thread Havoc Pennington
Hi, On Thu, Jul 10, 2008 at 6:10 AM, Andrew W. Nosenko <[EMAIL PROTECTED]> wrote: > Sorry for long delay, but could you please explain, how changing from >g_hash_table_size (GHashTable *hash_table); > to >g_hash_table_size (const GHashTable *hash_table); > would to break any C++ code? It

Re: GHashTable and const

2008-07-10 Thread Andrew W. Nosenko
On Thu, Jul 3, 2008 at 5:50 PM, Havoc Pennington <[EMAIL PROTECTED]> wrote: > Hi, > > On Thu, Jul 3, 2008 at 9:49 AM, Alberto Mardegan > <[EMAIL PROTECTED]> wrote: >> If I proposed a patch which adds some "const" here and there, would that be >> discarded a priori, or would it undergo a serious con

Re: GHashTable and const

2008-07-05 Thread Murray Cumming
On Fri, 2008-07-04 at 22:42 -0400, Mark Mielke wrote: [snip] > Why would a function taking a const parameter be calling a function with > the parameter that isn't defined to take a const? Because const means what you say it means. The compiler can't know. For instance, an internal cache or refere

Re: GHashTable and const

2008-07-04 Thread Milosz Derezynski
2008/7/4 Alberto Mardegan <[EMAIL PROTECTED]>: > ext Brian J. Tarricone wrote: > >> Now, that's for C. For C++ passing a const pointer to a function >> expecting a non-const pointer actually a hard *error*[1]. So the API >> couldn't be changed in this way without likely breaking any C++ applicat

Re: GHashTable and const

2008-07-04 Thread Mark Mielke
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

Re: GHashTable and const

2008-07-04 Thread BJörn Lindqvist
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 t

Re: GHashTable and const

2008-07-03 Thread Alberto Mardegan
ext Brian J. Tarricone wrote: Now, that's for C. For C++ passing a const pointer to a function expecting a non-const pointer actually a hard *error*[1]. So the API couldn't be changed in this way without likely breaking any C++ application that uses these glib data structures. Yes, but this

Re: GHashTable and const

2008-07-03 Thread Brian J. Tarricone
BJörn Lindqvist wrote: On Thu, Jul 3, 2008 at 3:49 PM, Alberto Mardegan <[EMAIL PROTECTED]> wrote: ext Havoc Pennington wrote: Whether you agree or not, the GLib types don't use const in their API, so if you try to use const yourself on these types you're just signing up for pain. It won't work

Re: GHashTable and const

2008-07-03 Thread BJörn Lindqvist
On Thu, Jul 3, 2008 at 3:49 PM, Alberto Mardegan <[EMAIL PROTECTED]> wrote: > ext Havoc Pennington wrote: >> Whether you agree or not, the GLib types don't use const in their API, >> so if you try to use const yourself on these types you're just signing >> up for pain. It won't work well or do anyt

Re: GHashTable and const

2008-07-03 Thread Mark Mielke
Havoc Pennington wrote: I'm not a GTK maintainer, but one problem with this is backward compatibility. Adding const can certainly break previously-working code, especially C++ code. This was an issued once faced when people migrated from K&R C to ANSI C. Nothing wrong with having a gconst t

Re: GHashTable and const

2008-07-03 Thread Havoc Pennington
Hi, On Thu, Jul 3, 2008 at 9:49 AM, Alberto Mardegan <[EMAIL PROTECTED]> wrote: > If I proposed a patch which adds some "const" here and there, would that be > discarded a priori, or would it undergo a serious consideration? > I'm not a GTK maintainer, but one problem with this is backward compat

Re: GHashTable and const

2008-07-03 Thread Mark Mielke
Morten Welinder wrote: "const" in C does not propagate as usefully as you would like. Therefore, the following sniplet is not violating C rules: struct Foo { int *x; }; int foo (const struct Foo *p) { *(p->x) = 1; } I don't think most languages propagate a "const"-like type. However, at lea

Re: GHashTable and const

2008-07-03 Thread Alberto Mardegan
ext Havoc Pennington wrote: Hi, This is in the archives a bunch of times, for example the first google hit I got was http://mail.gnome.org/archives/gtk-devel-list/2001-May/msg00485.html Ah, sorry, I only researched about GHashTable. Whether you agree or not, the GLib types don't use const in

Re: GHashTable and const

2008-07-03 Thread Havoc Pennington
Hi, This is in the archives a bunch of times, for example the first google hit I got was http://mail.gnome.org/archives/gtk-devel-list/2001-May/msg00485.html Whether you agree or not, the GLib types don't use const in their API, so if you try to use const yourself on these types you're just signi

Re: GHashTable and const

2008-07-03 Thread Morten Welinder
>> Because const in C is crippled, unlike in C++ where its actually useful. >> > > Soory, but you aren't right: Yes, he is, but you did not understand him. He was making a language comment, not an implementation comment. "const" in C does not propagate as usefully as you would like. Therefore,

Re: GHashTable and const

2008-07-03 Thread Andrew W. Nosenko
On Thu, Jul 3, 2008 at 2:34 PM, Ross Burton <[EMAIL PROTECTED]> 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 >> <[EMAIL PROTECTED]> wrote: >> > On 03/07/2008, Alberto Mardegan <[EMAIL PROTECTED]> wrote: >> >> Hi, quick

Re: GHashTable and const

2008-07-03 Thread Ross Burton
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 > <[EMAIL PROTECTED]> wrote: > > On 03/07/2008, Alberto Mardegan <[EMAIL PROTECTED]> wrote: > >> Hi, quick question: why do methods like > >> > >> g_hash_table_size() > >> g_hash_ta

Re: GHashTable and const

2008-07-03 Thread Andrew W. Nosenko
On Thu, Jul 3, 2008 at 2:11 PM, Rui Tiago Cação Matos <[EMAIL PROTECTED]> wrote: > On 03/07/2008, Alberto Mardegan <[EMAIL PROTECTED]> wrote: >> Hi, quick question: why do methods like >> >> g_hash_table_size() >> g_hash_table_lookup() >> >> don't accept a "_const_ GHashTable *" as first paramet

Re: GHashTable and const

2008-07-03 Thread Rui Tiago Cação Matos
On 03/07/2008, Alberto Mardegan <[EMAIL PROTECTED]> 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. Rui _

GHashTable and const

2008-07-03 Thread Alberto Mardegan
Hi, quick question: why do methods like g_hash_table_size() g_hash_table_lookup() don't accept a "_const_ GHashTable *" as first parameter? TIA, Alberto -- http://www.mardy.it <-- Geek in un lingua international! ___ gtk-devel-list mailing list gtk