I have a binary application statically linked to Tcl, and the front end is a Tcl interpreter. I would like to offer users the ability to use Python to execute the same commands as keyword variations. Sample Tcl syntax:
set_foo -foo 1.0 -bar 3.0 -cat x
so the python equivalent might look like this:
set_foo(foo=1.0, bar=3.0, cat="x")
Is it better to build the program twice, one as a Tcl application, one as a Python application? Or just save everything as Tcl, and you have a command that will call a Python script in its interpreter?
Commands are implemented in such a way that they do not know anything about the scripting language used. Api:
void set_fooCmd(Handler &data);
and Handler is a C ++ class that handles parsing parameters and provides them with a command implementation. So far, the Handler is implemented for Tcl, but not Python.
All code directly linked to Tcl is in its own directory and abstracts calls from the rest of the program.
Update: This is not a duplicate question: Choosing an interface / interpreter for scientific code
as they ask whether to move from Tcl to Python or Matlab. I already know that I want to support both Tcl and Python, and I would really like to know what approaches people used. For example:
- Python interpreter call from Tcl
- Compiling standalone applications for the front end of Python and the front end of Tcl.
- Another approach.
c ++ python api tcl
Juan
source share