In the following script :uplevel 0
is the filter, :uplevel 1
is the current
script (the filtered method), and uplevel 2
is the filter again, and
:uplevel 3
is finally the level m1 was called from. Shouldn't :uplevel 1
access the level m1 was called from?
Is the right answer perhaps to eliminate the :uplevel method, make the standard
uplevel command do the right thing in the case of nsf methods, and provide
special methods to do access filter contexts, if necessary?
nx::Class create c1
c1 public method m1 arg1 {
set a 7
puts [list {:uplevel 0} [:uplevel 0 set a]]
puts [list {:uplevel 1} [:uplevel 1 set a]]
puts [list {:uplevel 2} [:uplevel 2 set a]]
puts [list {:uplevel 3} [:uplevel 3 set a]]
puts [list {uplevel 0} [uplevel 0 set a]]
puts [list {uplevel 1} [uplevel 1 set a]]
puts [list {uplevel 2} [uplevel 2 set a]]
return
}
c1 public method f1 args {
set a 5
next
}
c1 filters add f1
c1 create obj1
proc p1 {} {
set a 3
obj1 m1 kk
}
set a 1
p1
output:
{uplevel 0} 7
{uplevel 1} 5
{uplevel 2} 3
{:uplevel 0} 5
{:uplevel 1} 7
{:uplevel 2} 5