<br>I am passing an array name by reference across an instproc. <br><br>The vanilla version works just fine (see creation of x1 midway through the code segment). <br><br>To add some debugging in, I essentially used the trace example from the tutorial, and funnily, 
<br>the upvar stopped doing it's job (see error on creating x2 towards the end of the code segment). <br><br>To get rudimentary debug control of the parray proc, I copied it into a proc called barray.&nbsp; None of the logic is changed - 
<br>just my crude attempt at adding breadcrumbs. <br><br>I have included the output at the end of the code segment. <br><br>Running Windows XP Pro + Active Tcl 8.4.13 + XoTcl 1.4.0. <br><br>thanks for all help. <br>-shishir
<br><br>&lt;CODE SEGMENT&gt;<br>package require XOTcl<br>namespace import ::xotcl::*<br><br><br>proc barray {a {pattern &quot;*&quot;}} {<br>&nbsp;&nbsp;&nbsp; puts &quot;barray&quot;<br>&nbsp;&nbsp;&nbsp; upvar 1 $a arr<br>&nbsp;&nbsp;&nbsp; if {![array exists arr]} {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error &quot;\&quot;$a\&quot; isn't an array&quot;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; set maxl 0<br>&nbsp;&nbsp;&nbsp; foreach name [lsort [array names arr $pattern]] {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if {[string length $name] &gt; $maxl} {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set maxl [string length $name]
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; set maxl [expr {$maxl + [string length $a] + 2}]<br>&nbsp;&nbsp;&nbsp; foreach name [lsort [array names arr $pattern]] {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set nameString [format %s(%s) $a $name]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts stdout [format &quot;%-*s = %s&quot; $maxl $nameString $arr($name)]
<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>Class X<br><br>X instproc bar {ar args} {<br>&nbsp; puts &quot;bar&quot;<br>&nbsp; upvar $ar arr<br>&nbsp; puts &quot;upvard&quot;<br>&nbsp; barray arr<br>}<br><br><br><br>X instproc init {args} {<br>&nbsp; array set arr {a 1 b 2}
<br>&nbsp; parray arr<br>&nbsp; my bar arr<br>}<br><br>X x1<br><br><br>Object Trace<br>Trace set traceStream stdout<br>Trace proc openTraceFile name {<br>&nbsp; my set traceStream [open $name w]<br>}<br>Trace proc closeTraceFile {} {<br>
&nbsp; close $Trace::traceStream<br>&nbsp; my set traceStream stdout<br>}<br>Trace proc puts line {<br>&nbsp; puts $Trace::traceStream $line<br>}<br>Trace proc add className {<br>&nbsp; $className instfilter [concat [$className info filter] traceFilter]
<br>}<br><br>Object instproc traceFilter args {<br>&nbsp; # don't trace the Trace object<br>&nbsp; if {[string equal [self] ::Trace]} {return [next]}<br>&nbsp; set context &quot;[self class]-&gt;[self callingproc]&quot;<br>&nbsp; set method [self calledproc]
<br>&nbsp; switch -- $method {<br>&nbsp;&nbsp;&nbsp; proc -<br>&nbsp;&nbsp;&nbsp; instproc {::set dargs [list [lindex $args 0] [lindex $args 1] ...] }<br>&nbsp;&nbsp;&nbsp; default {::set dargs $args }<br>&nbsp; }<br>&nbsp; Trace::puts &quot;CALL $context&gt; [self]-&gt;$method $dargs&quot;
<br>&nbsp; set result [next]<br>&nbsp; Trace::puts &quot;EXIT $context&gt; [self]-&gt;$method ($result)&quot;<br>&nbsp; return $result<br>}<br><br>Trace add X<br><br>X x2<br><br>&lt;/CODE SEGMENT&gt;<br><br>------------<br><br>&lt;OUTPUT&gt; 
<br>arr(a) = 1<br>arr(b) = 2<br>bar<br>upvard<br>barray<br>arr(a) = 1<br>arr(b) = 2<br>CALL ::xotcl::Object-&gt;&gt; ::x2-&gt;cleanup<br>EXIT ::xotcl::Object-&gt;&gt; ::x2-&gt;cleanup ()<br>CALL ::xotcl::Object-&gt;&gt; ::x2-&gt;configure
<br>EXIT ::xotcl::Object-&gt;&gt; ::x2-&gt;configure (0)<br>CALL ::xotcl::Object-&gt;&gt; ::x2-&gt;init<br>arr(a) = 1<br>arr(b) = 2<br>CALL ::xotcl::Object-&gt;init&gt; ::x2-&gt;bar arr<br>bar<br>upvard<br>barray<br>&quot;arr&quot; isn't an array
<br>&lt;/OUTPUT&gt;<br><br>----<br><br>&lt;ERRORINFO&gt;<br>% set errorInfo<br>&quot;arr&quot; isn't an array<br>&nbsp;&nbsp;&nbsp; while executing<br>&quot;error &quot;\&quot;$a\&quot; isn't an array&quot;&quot;<br>&nbsp;&nbsp;&nbsp; (procedure &quot;barray&quot; line 5)
<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;barray arr&quot;<br>&nbsp;&nbsp;&nbsp; (procedure &quot;bar&quot; line 6)<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;next&quot;<br>&nbsp;&nbsp;&nbsp; (procedure &quot;bar&quot; line 13)<br>&nbsp;&nbsp;&nbsp; ::x2 ::xotcl::Object-&gt;traceFilter
<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;my bar arr&quot;<br>&nbsp;&nbsp;&nbsp; (procedure &quot;init&quot; line 5)<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;next&quot;<br>&nbsp;&nbsp;&nbsp; (procedure &quot;init&quot; line 13)<br>&nbsp;&nbsp;&nbsp; ::x2 ::xotcl::Object-&gt;traceFilter
<br>&nbsp;&nbsp;&nbsp; ::X ::xotcl::Class-&gt;recreate<br>&nbsp;&nbsp;&nbsp; ::X ::xotcl::Class-&gt;create<br>&nbsp;&nbsp;&nbsp; ::X ::xotcl::Class-&gt;unknown<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;X x2&quot;<br>&nbsp;&nbsp;&nbsp; (file &quot;c:/temp/trace_trouble.tcl&quot; line 81)
<br>&nbsp;&nbsp;&nbsp; invoked from within<br>&quot;source c:/temp/trace_trouble.tcl&quot;<br clear="all">&lt;/ERRORINFO&gt;<br><br><br>