From: <no...@so...> - 2000-11-13 13:37:10
|
Bug #119372, was updated on 2000-Oct-25 22:11 Here is a current snapshot of the bug. Project: Tcl Category: Variables Status: Open Resolution: None Bug Group: 8.3.1 Priority: 5 Summary: Cannot set env array element via upvar #0 Details: OriginalBugID: 5991 Bug Version: 8.3.1 SubmitDate: '2000-07-06' LastModified: '2000-10-25' Severity: MED Status: UnAssn Submitter: techsupp OS: Windows NT OSVersion: Windows NT 4.0 Build 1381 SP6 Machine: x86 Family 6 Model 5 Stepping 2 AT/AT Compatible FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: David M. Eason Extensions: None CustomShell: No changes Comments: One workaround is to use "global env" and explicitly reference the desired element each time it is set. ReproducibleScript: array set inv {1 one 2 two} array set env {SSDIR c:/} proc setinv {n v} {upvar #0 inv($n) x; set x $v} proc setenv {n v} {upvar #0 env($n) x; set x $v} puts [setinv 1 won] ;#Displays "won" puts $inv(1) ;#Also displays "won" (this is correct) puts [setenv SSDIR d:/] ;#Display "d:/" puts $env(SSDIR) ;#Displays "c:/" (this is unexpected) ObservedBehavior: It appears that elements of the "env" array cannot be set using the upvar mechanism, but elements of other arrays can. The documentation states that upvar can be applied to array elements. Nothing special about "env" is noted on the help pages for array, tclvars, or upvar. DesiredBehavior: I expect to see the new value of the env array element in subsequent references. Follow-Ups: Date: 2000-Nov-13 05:41 By: dkf Comment: This is an unfortunate side effect of the way that variables in arrays are implemented (the contained variables do not know that they are contained within an array) and fixing it will require adding a field to struct Var to refer to the containing variable. An alternative would be to change the documentation for upvar, but that would be merely enshrining a misfeature in the cloak of "standard documented behaviour". :^( ------------------------------------------------------- For detailed info, follow this link: http://sourceforge.net/bugs/?func=detailbug&bug_id=119372&group_id=10894 |