doc: global and qualified varNames?
Closed / Fixed959831ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 21 years ago
Descriptionplain2004-05-25 01:44:07
The manual pages for global and upvar commands do not
explain the behaviour when the variable names contain
namespace qualifiers.
This is not so bad for upvar, as the behaviour is quite
intuitive. Not the same for global ...
One possibility is to explain global's behaviour, and
show that it could be defined as
proc global args {
if {[info level] < 2} {
return
}
set cmdName [namespace tail [lindex [info level
-1] 0]]
if {[info procs $cmdName] eq {}} {
return
}
set cmd [list upvar 0]
foreach var $args {
lappend cmd ::$var [namespace tail $var]
}
uplevel 1 $cmd
return
}
msofer Closed ticket [959831ffff].
[History diff]2004-05-25 21:11:58
msofer Open ticket [959831ffff].
[History diff]2004-05-25 21:28:47
msoferplain2004-05-25 23:58:43
Logged In: YES user_id=148712 Attached proposal for global.n; request comments
msoferplain2004-05-25 23:58:44
File Added - 88378: global.n
jenglishplain2004-05-26 01:29:41
Logged In: YES user_id=68433 New text looks good, though I'd suggest leaving out the part about "global can be defined in terms of other builtin commands as: [...]". The Tcl equivalent doesn't make things any clearer, since to understand it you first have to understand all the details of [info level], [namespace tail], [upvar], and [uplevel]. (Plus, I'm not sure it's even correct).
msoferplain2004-05-26 03:16:37
Logged In: YES user_id=148712 global.n fixed; upvar.n not yet ...
msoferplain2005-08-28 08:38:57
Logged In: YES user_id=148712 Moved the [upvar] issue to Bug #1274918, closed the ticket and changed the summary accordingly
msofer Ticket [959831ffff]: 2 changes
[History diff]2005-08-28 08:38:58
Log in (anonymous is fine) to add a comment.
Attachments:
- global.n [download] added by msofer on 2004-05-25 23:58:44. [details]