[Xotcl] proper way to access xotcl classes

Matthew Smith chedderslam at gmail.com
Wed May 7 19:54:20 CEST 2008

I am trying to learn xotcl classes and their use from the xotcl-
core.pdf examples.  Most of the code examples look like they are being
entered into a console while I am trying to write tcl files and then
run them.

Here's the class definition:
package require XOTcl
::xotcl::Class Stack
Stack instproc init {} {
# Constructor
my instvar things
set things ""

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

How do I access the class methods(i guess they are called) from within
the tcl file?
The examples show this:
# Create Object s1 of class Stack
% Stack s1
% s1 push a
% s1 push b
% s1 push c
% s1 pop
% s1 pop
# Delete object s1
s1 destroy

I have tried this:
set s1 [Stack]
puts $s1

Which outputs:

But I'm not sure where to go from here...
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20080507/0666c576/attachment.html 

More information about the Xotcl mailing list