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 least in theory, I think const would allow:

   struct Foo p;
   p->x = malloc(sizeof(int));
   foo(p);
   printf("%d\n", *(p->x));

To optimize the second p->x to be equal to a value from a register used during the initial assignment. If called in a tight inner loop with many iterations, the effect could be more significant.

While I cannot change p->x, I can change what
That said, it still wouldn't hurt to add const for cases like g_hash_table_size

I prefer prototypes to document intent as best as possible, even if the language does not allow for a direct match between intent and actual implementation. :-)

But, this is probably a waste of a thread as glib has done what glib has done.

Cheers,
mark

--
Mark Mielke <[EMAIL PROTECTED]>

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list

Reply via email to