[Ns-developers] Status of Python bindings

Gustavo Carneiro gjcarneiro at gmail.com
Fri May 16 14:31:20 PDT 2008


2008/5/16 <craigdo at ee.washington.edu>:

>
> > >          - Function (return_type, name, args) -> Function (name,
> > >         return_type,
> > >         args). The same would hold for add_cpp_method, of course.
> > >
> > > It occurred to me, since we're making API changes, would
> > this look to
> > > strange to you:
> > >
> > >     Function (name, args, return_type)
> > >
> > > This would allow me to make the return_type parameter
> > optional, which
> > > would be equivalent to void, and so simplify considerably definition
> > > of functions which do not return anything.  It would also make the
> > > ordering more in line with UML method description, which are like:
> > >
> > >    +methodName(parameters): return_type
> >
> > I am a bit uneasy about this: C++ makes the definition of function
> > _arguments_ optional (if none are defined, it is equivalent to 'void')
> > but always requires the definition of the return type. So,
> > your proposal
> > feels a bit awkward. Input from craig would be valuable.
>
> Sorry it took so long to get back to you.
>
> When I think of c++ bindings I think of taking a particular C++ function
> defined by a prototypical form and creating a function in
> the target language that matches the c++ prototype in a way that makes
> sense in the target language.
>
> This means that I think of it first from a c++-centric frame of mind
> (looking at the c++ function prototype) and then try and figure
> out how it would look (in this case) in Python and generate the code to
> make it so.
>
> So the declaration seems to me to be a statement of what the function
> prototype looks like in C++.  The return type is a required
> part of the function prototype.  So I agree with Mathieu here  - in the
> declaration of the C++ function signature to your bindings
> generator, you should have a required return_type just like your C++
> function declaration has a required return type.
>
> I would perhaps naively hope that the parameters in your declaration would
> appear in the same order as those in the C++ declaration.
>
>  Function (return_type, name, {arg type, argument},  ...)
>
> So I could just take a C++ declaration like,
>
>  void funcname (T1 P1, T2 P2);
>
> and almost mindlessly plug drop the pieces down into some Pythonic
> representation.
>
>  DeclareFunction (void, funcname, {T1, P1}, {T2, P2})


Sorry, I changed from (returntype, funcname, parameters) to (funcname,
returntype, parameters) following Mathieu's suggestion.  You didn't say
anything before and now it's too late.  Sorry.

Regarding returntype mandatory, fine by me; I'll keep it.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list