[C++-sig] Boost.Python code generator

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Dec 5 00:45:19 CET 2002


--- Nicodemus <nicodemus at globalite.com.br> wrote:
> The interface file would be as follows (the syntax is not fixed yet):
> 
> file A.pyi
> ------------------------------------------------------------------------
> include test/A.h        # this will just change to '#include "test/A.h"'
>                         # in the generated code, ie, the header
>                         # will not be actually parsed by pyste
> 
> class test.A(base test.B)
>     def foo (virtual void-int) # specify the return value and the parameters
>     def getName (return internal_reference)
> 
>     attr value
> ------------------------------------------------------------------------
> 

This is very interesting, but I am wondering how much you could actually cut
down on the typing. I believe David's restless mind has brought us already
fairly close to a hypothetical "most concise" syntax for defining the bindings
between a statically typed language and a dynamically typed language. If you
cross this boarder you will have to make certain decisions that are not already
encoded, you will have to specify additional information (i.e. which templates
to instantiate, return policies, pickle support, etc.). Scanning through my
source code I cannot identify too many places where one could hope for
significantly improved convenience. An obvious exception is this trivial
repetition:

  def("foo", foo)

That you could take care of with a macro such as:

#define DEF(function_name) def(# function_name, function_name)

giving you:

  DEF(foo)

Other than that you could maybe eliminate the need for certain punctuation such
as parentheses and semicolons but you have to buy this for the price of having
intermediate steps.

On the other hand ...

If you can identify a significant potential for cutting down on the typing you
might be able to hide those intermediate steps almost completely: your pyste
module could be a "Builder" in SCons (scons.sf.net). This is a fantastic build
tool for anyone using Python anyway/already.

Ralf


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com




More information about the Cplusplus-sig mailing list