[C++-sig] Re: Pyste: support for user defined code.

David Abrahams dave at boost-consulting.com
Sun Aug 17 23:50:08 CEST 2003


Nicodemus <nicodemus at globalite.com.br> writes:

> David Abrahams wrote:
>
>>Nicodemus <nicodemus at globalite.com.br> writes:
>>
>>  
>>>Agreed. There's not enough cases to justify the use of constants. I think:
>>>
>>>header_code()
>>>    
>>
>>  include('foo.hpp')
>>  
>
> Agreed, actually, I forgot such a function already exists, it is named
> Include. So, header_code was removed. 8)
>
>>>declaration_code()
>>>global_declaration_code()
>>>    
>>
>>  These two names are not very distinct.  What's the difference?
>>  
>
> declaration goes inside the empty namespace, together with the wrapper
> classes for instance. global declaration goes outside this namespace.

That seems very redundant.

    global_declaration_code('''
    namespace {
        ...
    }
    ''')


>>>module_code()
>>>    
>>
>>  hello.inject('''
>>        // my C++ code here
>>  ''')
>>
>>   hello.World.inject('''
>>        // my C++ code here
>>  ''')
>>  
>
> I assume "hello" is the module name. That doesn't work because a Pyste
> file doesn't know in which module it will generate the code (this is
> given in the command line). 

I based the suggestion on your example from the Pyste docs.

> Assuming "hello.World" is a class, then "inject" will put the code
> before or after the class? 

Within?

     hello.World.inject('.def("foo", ...)')

> I find that a code() call more clear than an inject method.

"declaration_code" seems a little redundant to me.  Aren't all
declarations code?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list