Quick question, probably for @VIRTUALDOG (or anyone familiar with interpreter internals) –
Does the interpreter know which Function or FunctionDef object is the source of the byte codes being executed at that moment? We have thisFunction
which might be enough, unless it has glitches in places.
There was just a thread on the user list about nowExecutingPath and scheduled functions. Currently, nowExecutingPath is available only synchronously – it’s cleared after the code block returns, and there’s no way to recover it automatically within scheduled functions. (We can save the path in a variable in the synchronous part of the code, and use it in a scheduled function.)
(
thisProcess.nowExecutingPath.debug("sync");
{ thisProcess.nowExecutingPath.debug("async") }.defer(0.01);
)
sync: /home/dlm/share/SC/scd/tests/execpath.scd
-> a Function
async: nil
If the interpreter can track back to the active FunctionDef object, then it would be possible to improve on this:
-
For every FunctionDef created within a synchronous block of code, save nowExecutingPath in a new member variable.
-
Then,
thisProcess.nowExecutingPath
could be replaced by a special byte code to access this variable.thisFunction
seems to be always a Function, and itsdef
is either a FunctionDef or a Method object. Method hasfilenameSymbol
but FunctionDef doesn’t – but if it did, then I think we could always get the executing path from it.
Just wondering how hard that would be.
hjh