Re: Intentional usage of old style function declarations? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Intentional usage of old style function declarations?
Date
Msg-id 24801.1439312863@sss.pgh.pa.us
Whole thread Raw
In response to Intentional usage of old style function declarations?  (Andres Freund <andres@anarazel.de>)
List 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 by date:

Previous
From: Robert Haas
Date:
Subject: Re: WIP: SCRAM authentication
Next
From: Robert Haas
Date:
Subject: Re: pg_dump and search_path