Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Substituted error stacks

Closed / Accepted523900ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 10 years ago
Descriptionplain2002-02-28 16:16:13
(summary of previous discussions with Jeff, Miguel et
al)

Idea: errorInfo gives only static source-level info
(line numbers and source excerpts), but not the actual
arguments gotten by the functions on the stack.

(1) This proposal is about creating a second global
variable, ::errorStack, which would be primarily a Tcl
list (until somebody asks for its string rep of
course), into which we'd stick all the dynamic info we
miss in errorInfo. The starting point is to store there
references to the substituted commands-and-args list of
the calling stack, which are available even at Tcl
level as [info level $n]. It is easy to do so while
respecting the current control flow of error stack: at
each level we store the info pertaining to the current
level, then we pop back. So this amounts to (in Tcl
pseudocode):

lappend ::errorStack [info level 0]

at the point where errorInfo is currently being built.

(2) Possible extension to this proposal: faster
reimplementation of errorInfo, leading to a much faster
[catch] in the negative (error) case. Principle:

- extend the above mechanism with file and line 
  number info from TIP#86, and store them 
  alongside the [info level]s in errorStack.

- remove all current errorInfo-construction 
  code (especially the line-counting loop !) 
  and reimplement errorInfo with a read trace, 
  reproducing exactly today's syntax but based 
  on the data in errorStack, and only if 
  errorInfo is used (which is not the case of 
  all [catch]es, hence the speed gain !).

I have posted a first step towards this in pure Tcl on
comp.lang.tcl. But clearly it suffers from all the
limitations of the current errorInfo construction
mechanism, which badly interacts with reentrant [eval]
of the Tcl code in any write trace on errorInfo !

Hence this proposal as a core patch, which would be
IMHO much more elegant (and simple, and efficient...)
than this pure-Tcl simulation
ferrieuxplain2002-03-25 23:14:22
Logged In: YES 
user_id=496139

The nobody is me: [email protected]
-Alex
dgpplain2002-03-25 23:42:42
Logged In: YES 
user_id=80530

Note: this is related to the work I'm doing on TIP 90.
Please keep me in the loop on this matter (or assign
this FR to me).
msoferplain2002-03-26 04:47:27
Logged In: YES 
user_id=148712

Handing off to Don - this really should be considered
together with TIP 90.
dgpplain2016-07-02 18:59:57
Did this become TIP 348 ?

Can it now be closed?
ferrieuxplain2016-07-02 22:07:27
Yes it did.
Yes it can.
Log in (anonymous is fine) to add a comment.