Re: Intentional usage of old style function declarations?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Intentional usage of old style function declarations?
Дата
Msg-id 24801.1439312863@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Intentional usage of old style function declarations?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> We have a bunch of callbacks that use old-style C function
> declarations. I.e. functions with empty parens allowing all types of
> data being passed:

> E.g.
> extern bool expression_tree_walker(Node *node, bool (*walker) (),
>                                    void *context);
> extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
>                                      void *context);

> I find that to be fairly ugly. Was that intentional?

Yes.  If we had the signature of the walker written out explicitly as say
     bool (*walker) (Node *node, void *context)

then every walker function would have to be declared that way (rather than
being declared with its true context pointer type), requiring casting away
from void * inside the walker.  Or else we could explicitly cast walker
function names to a typedef for walker_function everywhere we call
expression_tree_walker.  Both are notationally pains in the rear, and
what's more, either solution totally destroys the argument that you've
gained any type-safety.  I don't think a forced cast is better than a weak
declaration.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: WIP: SCRAM authentication
Следующее
От: Robert Haas
Дата:
Сообщение: Re: pg_dump and search_path