Re: DISCUSSION: Naming conventions (for C code)

Lance Ellinghouse (lance@markv.com)
Fri, 4 Jun 93 8:06:50 PDT

>Global variables are named using similar conventions, e.g.
>
>PyType_List
>Py_ZeroDivisionError

I think that variables should have the first letter after the
underscore in lowercase to distinguise them from functions...

>Typedefs contain no underscore; they consist of Py followed by one or
>more words with initial capitals, e.g.:
>
>PyObject
>PyListObject

I like having something like PyObject_t. This will make it easier to
look into the code and see if it is a typedef. It is also more
standard since most of ANSI typedefs are like that..

>Also note that pointer types will continue to be written with the "*"
>notation, e.g. "PyObject *". Pointers in C have sufficiently special
>semantics to make it important in practice to know whether a
>particular variable is a pointer; e.g. Python frequently uses casts
>between various object pointers.

I don't like this.. I like the following..

typedef struct _PyObject {
....
} PyObject_t, *pPyObject_t, **ppPyObject_t;

Or

typedef struct _PyObject {
....
} PyObject_t, *PyObjectP_t, **PyObjectPP_t;

This makes the code a little cleaner to read and makes it
harder to miss putting in a '*'.

>Other Changes
>=============
>
>It may be possible to introduce other changes as well, e.g. changes to
>the source tree: I might separate the .h files from the .c files,
>separate optional modules from the required part of the interpreter,
>move the parser generator to its own directory. (Anything else?)

Yes.. I would like to see it layed out like this for the source tree...

python/src/
python/src/h/
python/src/lib/modules/
python/src/lib/objects/
python/src/lib/parser/
python/src/lib/h/
python/src/optional/
python/src/optional/package_name/
python/lib/ /* This is where the libpython.a file gets put */
python/include/ /* each makefile when given the "install" flag puts */
/* "external" header files here */
python/bin/ /* This is where the executables gets put */
python/doc/
python/samples/
python/support/lib/ /* This is what the current 'lib' directory would become */

Each of the directories in src/lib/* and src/optional/* would have
it's own makefile. Thre would be a toplevel makefile in src that would
call each of the other makefiles...

just my ideas...

Lance Ellinghouse
lance@markv.com