[Python-Dev] Special-casing "O"

M.-A. Lemburg mal@lemburg.com
Sat, 26 May 2001 11:54:12 +0200


"Martin v. Loewis" wrote:
> 
> > I was thinking of using pointer indirection for this:
> >
> >       foo(PyObject *self, int *i)
> >
> > If i is given as argument, *i is set to the value, otherwise
> > i is set to NULL.
> 
> That is a good idea; I'll try to update my patch to more calling
> conventions.

This morning another idea popped up which could help us with
handling generic callings schemes:

	How about making *all* parameters pointers ?!

The calling mechanism would then just have to deal with an
changing number of parameters and not with different types
(this is how PyArg_ParseTuple() works too if I remember correctly).

We could easily provide calling schemes for 1 - n arguments
that way and the types of these arguments would be defined
by the parser string just like before.

Examples:

	foo(PyObject *self, PyObject *obj, int *i)
	bar(PyObject *self, int *i, int *j, char *txt, int *len)

To call these, the calling mechanism would have to cast these
to:

	foo(void *, void *, void *)
	bar(void *, void *, void *, void *, void *)

Wouldn't this work ?

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/