|
2008-10-03
| ||
| 06:04 | • Closed ticket [2134049fff]: info frame documentation error plus 7 other chan... artifact: f2808c66c9 user: andreas_kupries | |
|
2008-09-29
| ||
| 03:15 | • Ticket [2134049fff]: 1 change artifact: 300e3f3e13 user: dkf | |
|
2008-09-28
| ||
| 12:11 | • New ticket [2134049fff]. artifact: 99bc00cb3b user: lars_h | |
info frame documentation error
Closed / Fixed2134049fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-09-28 12:11:14
The description of what [info frame] does when given a positive level argument is as follows:
If number is positive (> 0) then it selects a particular
stack level (1 refers to the top-most active command,
i.e., info frame itself, 2 to the command it was called
from, and so on)
However, [info frame] is in practice almost never the top-most active command, so this is wrong. Defining
proc nest {levels} {
if {$levels<1} then {
for {set n 1} {$n<=[info frame]} {incr n} {
puts [format {%d: %s} $n [info frame $n]]
}
} else {
nest [incr levels -1]
}
}
one gets
% nest 3
1: type eval line 1 cmd {nest 3} level 4
2: type proc line 7 cmd {nest [incr levels -1]} proc ::nest level 3
3: type proc line 7 cmd {nest [incr levels -1]} proc ::nest level 2
4: type proc line 7 cmd {nest [incr levels -1]} proc ::nest level 1
5: type proc line 4 cmd {info frame $n} proc ::nest level 0
i.e., it is [info frame [info frame]] that selects the info frame call itself.
Also wrong is the claim that [info frame 2] provides information about the command from which [dict get [info frame 1] cmd] was called, since the above shows it is really the other way around: [dict get [info frame 1] cmd] caused [dict get [info frame 2] cmd] to be called.
The corresponding sentence in the description of [info level] describes these relationships correctly:
If number is positive then it selects a particular stack level
(1 refers to the top-most active procedure, 2 to the
procedure it called, and so on);
Possibly it is the use of "top-most" that confuses the issue (does the stack grow top to bottom or bottom to top?), so maybe it would be a good idea to replace this term by "outermost".
An alternative wording is:
If number is positive then it selects a particular
stack level (1 refers to the outermost active procedure,
2 to the procedure it called, and so on, up to the current
frame level which refers to the info frame itself);
dkf Ticket [2134049fff]: 1 change
[History diff]2008-09-29 03:15:44
andreas_kupriesplain2008-10-03 06:04:35
Committed to head. 'info level' is actually described in that way.
Log in (anonymous is fine) to add a comment.