API Shakeup: user data (was Re: [cairo] Patch improving fallbacks)
mental at rydia.net
mental at rydia.net
Thu Feb 24 12:56:24 PST 2005
Quoting Carl Worth <cworth at cworth.org>:
> Then, the only thing I have is some nit-picky questions about how
> to name callback types and arguments:
>
> > +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?
I can try...
Normally I dislike pointer-swallowing typedefs as well, but since
functions aren't a first-class data type in C, there's no risk of
the usual ambiguity.
On the other hand, since (at least in my experience) it's uncommon
to "split" a function pointer typedef to leave the asterisk in the
argument list, as a naive reader I'd be inclined to believe that in
e.g.:
void foo(bar_func_t *func);
bar_func_t was some structure used as a closure. Admittedly looking
up the definition of bar_func_t would still be required either way,
so I doubt there would be much confusion.
(ok, I tried...)
-mental
More information about the cairo
mailing list