Re: DISCUSSION: Naming conventions (for C code)

Guido.van.Rossum@cwi.nl
Sat, 05 Jun 1993 00:24:45 +0200

You say many wise words. Just one thing right now on an issue where I
won't give up easily...

> Using this conventions will make it less convienent to use a very
> useful information hiding trick. Often, the definition of a structure
> only needs to be known within the module that uses it. The public
> header file can then declare a typedef as a pointer to the structure
> without specifying the structure at all. Using this convention will
> either force all structure defination to be exposed in the public
^^^^^^
> header files.

Actually, it is completely legal in C (even pre-ANSI C!) to do things
like

struct unknown_tag *p; /* pointer to unknown structure */

and

typedef struct unknown_tag opaque_t; /* opaque typedef */

where "struct unknown_tag" is not defined in the current file.

The latter makes it possible to declare pointers to opaque_t objects
but not to declare opaque_t objects (then the compiler will say
"unknown size" or so).

As a compromise I can see defining both, say, PyObject and PyObjectPtr,
so I can write "PyObject *p" and you can write "PyObjectPtr p". I can
read the latter style but prefer to write the former; I suppose for
you it's the other way around :-)

(I'm still waiting for the "or" part of your last sentence here...)

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>