[Bf-python] naming conventions, some propositions, and some misc reflexions...
Jacques Guignot
guignot at wanadoo.fr
Thu Jun 19 15:49:31 CEST 2003
Willian Padovani Germano wrote:
>
>>From now on we'll be discussing the restructuring, including function
>naming conventions (I'll send an email about that in a few days), etc.,
>please reply with your opinions. The idea is not to bother everyone with
>random changes, we want consistency : ).
>
>
Some propositions :
a) The C functions are prefixed with the module name, and underscore for
readability, followed by "get" or "set" and the name of the field (or
group of fields)
examples :
static PyObject *World_getName(C_World *self)
static PyObject *World_setName(C_World *self, PyObject *args)
b) The corresponding python functions are the same, without the module
name :
example :
getName, setName
c) Intern and helper functions : no rule
d) keywords for the "getattr" and "setattr" : use the names of the
fields in the corresponding C structure (they are generally well choosen)
e) in "getattr" and "setattr" : try to reuse the corresponding the
existing functions.
example :
static PyObject *World_GetAttr (C_World *self, char *name)
{
if (strcmp (name, "name") == 0)return World_getName (self);
counter example (sorry, Willian!) :
if (strcmp(name, "name") == 0)
attr = PyString_FromString(self->camera->id.name+2);
f) I think that the speed factor should be considered as not very
important. It is crucial for guys working on rendering or computation of
the image. Not for us, an intepreter is not very fast by nature.
g) Arguments : for compound objects (coordinates or color values for
instance) the "get" functions will rerturn a list. The "set" functions
will accept a list as argument.
More information about the Bf-python
mailing list