API Shakeup: user data (was Re: [cairo] Patch improving fallbacks)
Owen Taylor
otaylor at redhat.com
Thu Feb 24 12:07:08 PST 2005
On Thu, 2005-02-24 at 13:33 -0500, Carl Worth wrote:
> > +typedef void (*cairo_destroy_func_t) (void *data);
>
> I think I'd prefer to have the '*' in the argument list rather than
> swallowed up inside the typedef. I think this is consistent with my
> general distaste for pointer-swallowing typedefs. But there may be a
> compelling argument for a function-pointer exception to the
> rule. Anyone have one?
Do you know of any examples of libraries that don't swallow the
* inside function typedefs? I can't think of ever seeing that,
to the point I had to try it out to be sure that:
typedef void (cairo_destroy_func_t) (void *data);
is even legal C. It would certainly be inconsistent with the GTK+
stack.
The above typedef is also weird because it defines something
that can't be used in isolation.
> And "func" is an abbreviation I missed when I went hunting. Shall we
> just use "function" instead? I don't think the length is anything to
> worry about since the user never needs to type this name.
Actually, (GDestroyNotify) is one of the most common casts to type
in GTK+ programming, since it's easier to define:
void my_thing_destroy (MyThing *thing);
Then my_thing_destroy (void *thing). I think _func() gets into the
class of things that are so universal that the abbreviation doesn't
add significant unclarity.
Regards,
Owen
More information about the cairo
mailing list