I copy and pasted what you posted, and still get the error:<br>invalid command name "s1"<br><br><div class="gmail_quote">On Thu, May 8, 2008 at 10:59 AM, Gustaf Neumann <<a href="mailto:neumann@wu-wien.ac.at">neumann@wu-wien.ac.at</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Matthew Smith schrieb:<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Putting in:<br>
s1 push a<br>
results in an error, however I can do:<br>
<br>
what is the error? this indicates that you have not defined the method push correctly<br>
<br>
I get:<br>
invalid command name "s1"<br>
</blockquote></div>
this indicates, that you have not created an object s1. Your program<br>
should look like the following.....<div class="Ih2E3d"><br>
<br>
hope this helps<br>
-gustaf neumann<br>
<br></div>
===========================================<div class="Ih2E3d"><br>
package require XOTcl; namespace import ::xotcl::*<br>
<br></div><div class="Ih2E3d">
Class Stack<br>
Stack instproc init {} {<br>
my instvar things<br></div><div class="Ih2E3d">
set things ""<br>
}<br>
Stack instproc push {thing} {<br>
my instvar things<br>
set things [concat [list $thing] $things]<br>
return $thing<br>
}<br>
Stack instproc pop {} {<br>
my instvar things<br>
set top [lindex $things 0]<br>
set things [lrange $things 1 end]<br>
return $top<br>
}<br>
<br>
set s1 [Stack new]<br>
<br></div>
s1 push a<br>
s1 push b<br>
<br>
set x [s1 pop]<br>
puts "The popped value is $x"<br>
===========================================<br>
<br>
</blockquote></div><br>