Am Montag, den 14.01.2013, 07:45 -0500 schrieb Matthew Barnes:
> On Mon, 2013-01-14 at 10:24 +0100, Milan Crha wrote:
> > I noticed some time ago that the code is "full" of redundant type casts,
> > but I do not understand what it is good for.
>
> For better readability, in cases where the type definition also hints at
> what the callback does.
I support Milan's request for removing them: C is a language with static
typing and one of the advantages of static typing is that the compiler
helps preventing tiny but hazardous mistakes. Like passing a callback
with wrong signature. With casts you disable that feature and add
another problem to watch for to the already way too long list of C
traps. If the only reason for using those casts is documentation, it
makes much more sense to put comments in front or behind the arguments.
backend->priv->jobs = g_hash_table_new_full (
/* GHashFunc */ g_direct_hash,
/* GEqualFunc */ g_direct_equal,
/* GDestroyNotify */ NULL,
/* GDestroyNotify */ g_object_unref);
or:
backend->priv->jobs = g_hash_table_new_full (
/* key-hash-func */ g_direct_hash,
/* key-equal-func */ g_direct_equal,
/* key-destroy-func / NULL,
/* value-destroy-func */ g_object_unref);
Let's use the intended tools to solve our problems.
Ciao,
Mathias
_______________________________________________
evolution-hackers mailing list
[email protected]
To change your list options or unsubscribe, visit ...
https://mail.gnome.org/mailman/listinfo/evolution-hackers