Re: ANSI-strict pointer aliasing rules - Mailing list pgsql-hackers

From Greg Stark
Subject Re: ANSI-strict pointer aliasing rules
Date
Msg-id 87hd4e7rd2.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: ANSI-strict pointer aliasing rules  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ANSI-strict pointer aliasing rules
Re: ANSI-strict pointer aliasing rules
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Greg Stark <gsstark@mit.edu> writes:
>
> > There are other ways of achieving the same thing. Structs containing a union
> > for the subclass fields for example.
> 
> Doesn't achieve the same thing, unless you mandate that every part of
> the system use the identical massively-overloaded union struct to refer
> to every node.  

Are you saying it's important to preserve the ability for modules to add new
node types without notifying the rest of the code? I thought all the node
types were defined in a single header file currently anyways.

> That would (a) defeat the purpose of extensibility, and (b) make the code
> more error prone not less so (since it'd be notationally easy to refer to a
> field that's not actually present in the given node subtype).

You could use a local pointer to be preserve the existing model of a single
point where the decision is made. That could be encapsulated in a macro that
included an assertion to verify the type tag.

It would be pretty cool to have a type-safe codebase. It just seems like too
an awful lot of work for a mostly aesthetic improvement.

-- 
greg



pgsql-hackers by date:

Previous
From: "Larry Rosenman"
Date:
Subject: Re: Logging pg_autovacuum
Next
From: Taral
Date:
Subject: Re: ANSI-strict pointer aliasing rules