[C++-sig] TnFOX with the latest py++ from SVN

David Abrahams dave at boost-consulting.com
Tue Oct 3 05:06:35 CEST 2006


"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 2 Oct 2006 at 9:15, David Abrahams wrote:
>
>> >> Surely BPL can rebind the value of sx on output back to the input? I
>> >> remember something in the tutorial about this just working out of the
>> >> box.
>> >
>> > No it can not. In near future it will be very easy to instruct Py++ to
>> > create wrapper
>> > for such functions.
>> 
>> But even with a wrapper it's never going to automagically rebind
>> anything, FWIW.
>
> I'm probably being stupid, but surely if you pass by non-const 
> reference then you *expect* it to change?
>
> Of course, modified in C++ is not modified in Python where basic 
> types are immutable. But it does seem a reasonable approximation that 
> as a default, the python parameter is rebound to the output value for 
> integral types.

There is absolutely no way for the function to detect which variable (if any) 
the original value was bound to.

    f(x + y)

is an example where it wasn't bound to anything.

You could try to do something unspeakable, like looking back up the python
traceback and decompiling the code of the caller to figure it out, but
even if that could work sometimes, it wouldn't work all the time.
Anyway, if you want to try to implement such an abomination, more
power to you, but it will never go into Boost.Python.

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




More information about the Cplusplus-sig mailing list