I copy and pasted what you posted, and still get the error:
invalid command name "s1"
Matthew Smith schrieb:this indicates, that you have not created an object s1. Your program
Putting in:
s1 push a
results in an error, however I can do:
what is the error? this indicates that you have not defined the method push correctly
I get:
invalid command name "s1"
should look like the following.....===========================================
hope this helps
-gustaf neumann
package require XOTcl; namespace import ::xotcl::*
Class Stack
Stack instproc init {} {
my instvar thingsset things ""s1 push a
}
Stack instproc push {thing} {
my instvar things
set things [concat [list $thing] $things]
return $thing
}
Stack instproc pop {} {
my instvar things
set top [lindex $things 0]
set things [lrange $things 1 end]
return $top
}
set s1 [Stack new]
s1 push b
set x [s1 pop]
puts "The popped value is $x"
===========================================