On 2018-12-05 15:29, heinrichmartin wrote:
> TCL_ABORT is not standard Tcl, is it?
Just an example of unwind idea.
> Be aware that the script must deal (or actually must not deal) with the exception to make this work. I.e. a [catch] could silently ignore your interception.
I would like to kill interpreter regardless of way script handles
exception. I prefer *not* to emit TCL exception, I prefer to emit C++
exception or any other way to jump out of TCL_*Eval*.
> Also, by strictly denying any further action, you will prevent execution of cleanup code, too.
Does not really matter. In my scenario tcl is embedded in application.
One just clicked "quit" in application while script was running. I have
no way to pause/break tcl script except for low level thread interrupt
that can destroy not only tcl internal state but also mine.
Did already asked for coroutine NRE solution but TCL does not have one,
instead there is "do everything in one call including hang" solution. In
other words I am a prisoner of TCL internal loop and there is no way to
escape.
>> c) I do not want to use trace since it is slow.
> Have you tried?
Yes. It is.
> On C level, you could really just check a (global) flag and return anything but TCL_OK.
From where? In case of tight loop that is compiled to bytecode there is
no escape and no way to return anything for me. TCL is just having fun
inside it's internals and I'm not invited to this party.
> Obviously, your script must be aware of your special break code.
No way, random user can and will create tight loop inside embedded tcl
and report bug to me that application hangs.
> Also see the TCL_ALLOW_INLINE_COMPILATION flag.
Will not help much on speed in real examples.
> Not a core dev here, but quite sure that Tcl_CreateObjTrace is *not* thread safe.
I bet it is not. I'm out of ideas how to break tcl NRE engine in legal
way since no TCL developer figured out single step NRE as public API.