Get current line and file from C++


Is there any way to get the current line of code that ChaiScript is executing from C++? For example, this is what you would do in Lua:

lua_Debug ar;
lua_getstack(L, 1, &ar);
lua_getinfo(L, "Sl", &ar);
int line = ar.currentline;
std::string file = ar.source;

(code partially ripped from here)


That would be useful for custom error report in editors. I am working on something like this inside my game-specific editor.


It would be possible if you added your own Tracer object in the current development branch.

This is all very experimental right now. But if I were to actively track the current location being executed it would add unnecessary overhead, but if that’s a feature you need, the Tracer could be a good option.

Here is an example from the unittests