Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-31
00:46
Merge [e7da24db33402408]: Improve [2da1cb0c80] fix. check-in: 0e3f40e75f user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
00:43
Merge [78610815d04df320]: Make varname method handle array elements better. [2da1cb0c80]. check-in: d7bf4812e8 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-08-07
14:44 • Ticket [2da1cb0c80] $obj varname handling of linked variables status still... artifact: 2504b5aa36 user: dkf
09:30
Improve [2da1cb0c80] fix. check-in: e7da24db33 user: dkf tags: trunk, main
09:17
An imperfect fix for [2da1cb0c80] given that can't do the right thing check-in: 8063b4eb59 user: dkf tags: core-8-branch
09:06
An imperfect fix for [2da1cb0c80] given that can't do the right thing check-in: 951caef54b user: dkf tags: core-8-6-branch
2024-08-06
21:02 • Closed ticket [2da1cb0c80]: $obj varname handling of linked variables plus... artifact: 2e8cecc7c1 user: dkf
21:01
Make varname method handle array elements better. [2da1cb0c80] check-in: 78610815d0 user: dkf tags: trunk, main
2024-05-23
13:49 • Ticket [2da1cb0c80] $obj varname handling of linked variables status still... artifact: 4e119336ad user: dkf
2019-12-20
15:56 • Ticket [2da1cb0c80]: 3 changes artifact: 24930d2163 user: dkf
2018-05-08
13:58 • Ticket [2da1cb0c80]: 4 changes artifact: f8cc3b40e1 user: dgp
13:57 • New ticket [2da1cb0c80]. artifact: 14369d61f0 user: dgp

[$obj varname] handling of linked variables

Closed / Fixed2da1cb0c808499bbd1d37e3a50291a26f8a46e14Created 9 years agoUpdated 2 years ago
Descriptionplain2018-05-08 13:57:08
% set o [oo::object new]
::oo::Obj11
% oo::objdefine $o export eval varname
% $o eval {namespace upvar :: nosuch test}
% $o varname test
::nosuch

Why not '::oo::Obj11::test' ?

% $o eval {namespace upvar :: tcl_platform(platform) foo}
% $o varname foo
%

Why not '::tcl_platform(platform)' ?

Or why not '::oo::Obj11::foo' ?

Is this behavior sensible? What should sensible behavior be and why?
Referenced by6
dgp Ticket [2da1cb0c80]: 4 changes [History diff]2018-05-08 13:58:22
dkfhtml2019-12-20 15:56:36

The first case works well enough (it is returning a handle to the correct variable) even if it is unexpected (due to following the rabbit hole of variable links).

The second case is a definite bug.

dkfmarkdown2024-05-23 13:49:41

The behaviour in the second case is due to:

    if (!varPtr || TclIsVarArrayElement(varPtr)) {
	return;
    }

in Tcl_GetVariableFullName() in tclVar.c. That is unexpected to me! (The function is only documented — in its header comment — to work with the results of Tcl_FindNamespaceVar(), but even so...)

dkfmarkdown2024-08-06 21:02:49

Fixed in 9.0, and not much prospect of backporting; it needs the new TclVarParentArray() macro (and supporting structure fields).

dkfplain2024-08-07 14:44:52
I've added a hack for 8.6 and 8.7 that returns the name of the variable within the object when it has no better option.
Log in (anonymous is fine) to add a comment.