Index: library/lib/upvarcompat.xotcl =================================================================== diff -u -rc72f9f638677608fab1502cd696c8f2d6b2952f9 -r2111020b49da8ce57758e51accf0b6073037f0d2 --- library/lib/upvarcompat.xotcl (.../upvarcompat.xotcl) (revision c72f9f638677608fab1502cd696c8f2d6b2952f9) +++ library/lib/upvarcompat.xotcl (.../upvarcompat.xotcl) (revision 2111020b49da8ce57758e51accf0b6073037f0d2) @@ -10,7 +10,7 @@ Provide a version of upvar and uplevel that provide backward compatibility such that these commands ignore inactive filter and mixin frames (upvar behaves - the same whether or not a filter is installed). Newer + the same whether or not a filter is installed). Newer scripts should use <@TT>upvar/uplevel [self callinglevel] var/command instead. } } @@ -20,23 +20,33 @@ # otherwise point to the callinglevel from XOTcl rename ::uplevel ::xotcl::tcl_uplevel proc ::uplevel {lvl args} { - # the outer uplevel is needed to leave the scope of this proc - if {[regexp {^\#?[0-9]+$} $lvl]} { - ::xotcl::tcl_uplevel 1 [list eval ::xotcl::tcl_uplevel $lvl $args] - } else { - set cl [::xotcl::tcl_uplevel 1 ::xotcl::self callinglevel] - ::xotcl::tcl_uplevel 1 [list eval ::xotcl::tcl_uplevel $cl [list $lvl] $args] - } + set cl [::xotcl::tcl_uplevel 1 ::xotcl::self callinglevel] + if {[string match #* $cl]} { + # we were called from XOTcl, use the XOTcl method + set cmd [concat [list my uplevel $lvl] $args] + } else { + # no XOTcl in sight, use tcl variant + set cmd [concat [list ::xotcl::tcl_uplevel $lvl] $args] + } + #puts stderr cmd=$cmd + set code [catch [list ::xotcl::tcl_uplevel 1 $cmd] msg] + return -code $code $msg } rename ::upvar ::xotcl::tcl_upvar proc ::upvar {lvl args} { - # the outer uplevel is needed to leave the scope of this proc - if {[regexp {^\#?[0-9]+$} $lvl]} { - ::xotcl::tcl_uplevel 1 [list eval ::xotcl::tcl_upvar $lvl $args] - } else { - set cl [::xotcl::tcl_uplevel 1 ::xotcl::self callinglevel] - ::xotcl::tcl_uplevel 1 [list eval ::xotcl::tcl_upvar $cl [list $lvl] $args] - } + set cl [::xotcl::tcl_uplevel 1 ::xotcl::self callinglevel] + if {[string match #* $cl]} { + # we were called from XOTcl, use the XOTcl method + set cmd [concat [list my upvar $lvl] $args] + #set code [catch {my uplevel $lvl $args} msg] + } else { + # no XOTcl in sight, use tcl variant + set cmd [concat [list ::xotcl::tcl_upvar $lvl] $args] + } + set code [catch [list ::xotcl::tcl_uplevel 1 $cmd] msg] + return -code $code $msg } +puts stderr HU +