Skip to content
Tcl Source Code View Ticket
Login

View Ticket

upvar and unset and traces: change in HEAD correct?

Deleted1749596fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-07-07 13:45:29
mig@uh:~$ tclsh8.4
% upvar 0 a(x) y
% proc moo args {trace add variable ::a(x) unset moo; set ::y 1}
% moo
1
% unset a
% parray a
% set y
can't read "y": no such variable
% set y 1
can't set "y": upvar refers to element in deleted array

versus
 
mig@uh:~$ /home/CVS/tcl_SF_clean/unix/tclsh
% upvar 0 a(x) y
% proc moo args {trace add variable ::a(x) unset moo; set ::y 1}
% moo
1
% set y
1
% parray a
a(x) = 1

What this means is that upvar in HEAD has snapshot semantics that are "less pure" than 8.4
msoferplain2007-07-07 20:51:13
Logged In: YES 
user_id=148712
Originator: YES

OTOH both versions react similarly (impure snapshot semantics) to unsetting the element:

% upvar 0 a(x) y
% proc moo args {trace add variable ::a(x) unset moo; set ::y 1}
% moo
1
% unset a(x)
% set y
1
msoferplain2007-07-07 20:58:24
Logged In: YES 
user_id=148712
Originator: YES

Tcl8.0.5 and Tcl8.3.4 behave just like Tcl8.4 in this respect - HEAD is really innovating, 8.5a5 has the traditional behaviour. This is due to the recent "streamlining" changes in variable deletion :(
msoferplain2007-07-07 21:08:42
Logged In: YES 
user_id=148712
Originator: YES

Stupid pilot error: same behaviour if the scripts really are identical, forgot the 'unset' in HEAD.
Log in (anonymous is fine) to add a comment.