Re: libpq object hooks - Mailing list pgsql-patches

From Tom Lane
Subject Re: libpq object hooks
Date
Msg-id 17534.1210951450@sss.pgh.pa.us
Whole thread Raw
In response to Re: libpq object hooks  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-patches
"Merlin Moncure" <mmoncure@gmail.com> writes:
> Switch, plus struct (basically a union) will do the trick nicely.  Can
> it be a formal union, or is it better as a void*?

I don't think a union buys much notational convenience or safety here,
although admittedly it's a close question.  In one case you're trusting
to cast the pointer to the appropriate type, in the other you're
trusting to use the right union member.  One advantage of separate
structs is that there's no reason not to make the struct type names
long enough to be clear, whereas there's a very strong notational
temptation to make union member names short, because you'll be typing
them a lot.

            regards, tom lane

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: libpq object hooks
Next
From: Tom Lane
Date:
Subject: Re: libpq object hooks