* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > Force references to go through macros which implement the lookup for the > > appropriate type? ie: LOGICAL_COL(table_oid,2) vs. > > PHYSICAL_COL(table_oid,1) Perhaps that's too simplistic. > > It doesn't really address the question of how you know which one to > use at any particular line of code; or even more to the point, what > mechanism will warn you if you use the wrong one.
That'd be the point of doing the typing, you then declare functions as accepting the type and then if someone passes the wrong type to a function the compiler will complain. Inside of a particular function it would hopefully be easier to keep it clear. I'd think that most functions would deal with one type or the other (which would be declared in the arguments or in the local variables) and that functions which have to deal with both would be able to keep them straight. > My gut feeling about this is that we could probably enforce such a > distinction if we were using C++, but while coding in C I have no > confidence in it. (And no, that's not a vote to move to C++ ...) I need to go research what Linux does for this because aiui it's pretty good about being able to enforce better type-checking than the stock C types. The only downside is that I *think* it might be a GCC-only thing. In that case I'd think we would still use it but build some macros which essentially disable it for non-GCC compilers. As a mainly-for-developers compile-time check I think as long as a build-farm member is running GCC and complaining when there are errors (and it can be disabled on non-GCC compilers) we won't lose any portability from it. Thanks, Stephen
signature.asc
Description: Digital signature