home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!cs.utexas.edu!tamsun.tamu.edu!inetg1!cgp
- From: cgp@Arco.COM (Chris Phillips (214) 754-6419)
- Newsgroups: comp.lang.tcl
- Subject: uplevel/upvar and trace
- Message-ID: <1992Jul22.203440.15926@Arco.COM>
- Date: 22 Jul 92 20:34:40 GMT
- Article-I.D.: Arco.1992Jul22.203440.15926
- Distribution: usa
- Organization: ARCO Oil and Gas Company
- Lines: 47
-
- Apparently there is no difference in
-
- proc s1 {n i op} {
- set z [uplevel set [set n]]
- puts stdout $z
- }
- and
- proc s2 {n i op} {
- upvar $n z
- puts stdout $z
- }
-
- For example,
-
- tcl>trace var a w s1
- tcl>set a 5
- 5
- tcl>trace vdel a w s1
- tcl>trace var a w s2
- tcl>set a 5
- 5
- tcl>
-
- However, the following extensions to arrays doesn't work
- for the upvar version:
-
- proc a1 {n i op} {
- set z [uplevel set [set n]($i)]
- puts stdout $z
- }
- proc a2 {n i op} {
- upvar [set n]($i) z
- puts stdout $z
- }
-
- tcl>trace var b(1) w a1
- tcl>set b(1) 2
- 2
- tcl>trace vdel b(1) w a1
- tcl>trace var b(1) w a2
- tcl>set b(1) 2
- Error: can't set "b(1)": access disallowed by trace command
- tcl>
-
- Why?
-
- Chris
-