[C++-sig] Re: Re: boost::python::api

Dave Hawkes daveh at cadlink.com
Wed Jul 10 19:22:45 CEST 2002


"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:0e5c01c22829$f66a3180$6601a8c0 at boostconsulting.com...
> This
> > just seems to be giving the user additional restrictions on how the code
> is
> > structured.
>
> I don't see how. The user is free to bind local variables, including one
> called 'rtn'. If he wants a value back, he just writes "return rtn", or if
> he doesn't want to use a local variable he can just write "return
> <expression>". Simple and pythonic.
>


> > If we have a fixed set of variable names going in as arguments
> > it doesn't seem to be that illogical to have a fixed variable name for
> the
> > return value as well.
>
> It's not illogical in principle, but it's not Pythonic (more Pascal-ish).
>
> > Also wrapping in a function body will incur additional overhead as I
> think
> > the only way I can get a variable back from exec is through the local
> > dictionary anyway.
>
>     "def f__:\n" + body + "ret = f__()\n"
>
But what if the user wants to add functions or classes to the global
namespace, if the user defines a function/class in "body" then they will be
defined within f__ namespace. Not what the user intended. I know the user
could write code to get at the global namespace, but then that's not
particularly simplistic.

>
> > Additionally I am probably going to have to provide an additional
> argument
> > to call_statement to specify whether the python global namespace should
> be
> > polluted by the call or not.
>
> Hmm. I don't see how that changes the question of "return", though.
>
Not directly apart from when the user wants to modify the global namespace
and the function wrapper gets in the way, as above.

>
> > As above. I think we should stick to a return variable, whatever it is
> > called.
>
> It rubs all my stylistic hairs in the wrong direction. If it's really hard
> to do anything else, I'll acquiesce, but I'm not convinced yet.
>
Maybe, but in the long run I think it will make things harder for the user
for the sake of purity.

Dave Hawkes










More information about the Cplusplus-sig mailing list