[C++-sig] Re: [BPL] python::interpreter proposal
Dirk Gerrits
dirk at gerrits.homeip.net
Thu Jan 2 19:27:34 CET 2003
Nicodemus wrote:
> Dirk Gerrits wrote:
>
>> Hmm that's quite a showstopper. Perhaps a second enum parameter is
>> needed? Something like:
>>
>> enum code_type
>> { single_expression, single_statement, multiple_statements };
>>
>> Not very nice IMHO so if anyone knows a way around it, please
>> enlighten me. ;)
>>
>> Dirk Gerrits
>>
>>
> I think two separate functions would be better.
>
> void interpreter::exec( const std::string& code, dict& globals, dict&
> locals );
> - Executes the given code in the context of the two given dictionaries.
>
> object interpreter::eval( const std::string& expr, dict& globals, dict&
> locals );
> - Evaluates the Python expression given, in the context of the two
> dictionaries, and returns the resulting object.
>
> They're equivalent to the "exec" statement and to the "eval" builtin
> function in python.
I like that. Let's hear what others think about it.
Dirk Gerrits
More information about the Cplusplus-sig
mailing list