Author: Leon Manukyan <email@example.com> State: Draft Type: Project Vote: Pending Created: 13-Dec-2018 Tcl-Version: 8.6, 8.7 Post-History: Tcl-Ticket: a09031e288
A compile-time macro and an environment variable are introduced which enable a user of Tcl to trade some functionality brought by  for better performance.
Background and Motivation
 extended Tcl's abilities for introspection with the info frame command able to determine the location of its call, i.e., the name of the file the code is in, and the absolute line number in that file.
Though that functionality was very useful while debugging Tcl scripts it hardly had any other use, while at the same time negatively impacting the performance of Tcl code.  has already addressed the most critical degradation of performance caused by , however a milder slowdown has remained. The mere fact that line continuations are tracked unconditionally and such information, if present, is associated with a respective Tcl object through an external hash map results in a relatively expensive check performed in TclFreeObj() for every single object. The issue has first been discussed at comp.lang.tcl.
This TIP now proposes to put the execution of the respective part of 's implementation under user control, allowing them to trade info frame-exactness for speed, and vice versa.
The environment variable
checked during the startup of the main Tcl interpreter and handling of line
continuations is fixed till the end of execution as follows:
If the value of that environment variable is 0, then line continuations (backslash+newline) sequences are not tracked (thus resulting in improved performance) and the line numbers returned by
info framemay be wrong.
For any other value of that environment variable the line continuations are tracked and correct line numbers are reported by
The default value assumed for the environment variable
TCL_INFO_FRAME_ENABLE_ACCURATE_LINE_NUMBERS when it is unset is defined by the
compilation macro of the same name. That is a Tcl interpreter built with
-DTCL_INFO_FRAME_ENABLE_ACCURATE_LINE_NUMBERS=X will behave by default
as if the env var
TCL_INFO_FRAME_ENABLE_ACCURATE_LINE_NUMBERS is set to
(but the actual value of that variable, if it is set, will be respected).
Unless users don't take any deliberate action (assuming that they didn't use the said compilation macro in their build processes or the environment variable in their flows) they won't notice any change in behavior.
A reference implementation is provided at https://core.tcl.tk/tcl/artifact/3b68b7cd8131a42a .
This document has been placed in the public domain.