[Xotcl] proper way to access xotcl classes

Kristoffer Lawson setok at scred.com
Wed May 7 20:01:36 CEST 2008


On 7 May 2008, at 20:54, Matthew Smith wrote:

>
> ---------------------------------------------------------
> 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
> % s1 push a
> a
> % s1 push b
> b
> % s1 push c
> c
> % s1 pop
> c
> % s1 pop
> b
> # Delete object s1
> s1 destroy
> --------------------------------------------------------
> I have tried this:
> set s1 [Stack]
>

Either this:

set s1 [Stack new]

or

set s1 [Stack s1]

The first version gives you an automatically named object, which is  
probably what you usually want to do. You can also explicitly name  
objects with the latter version (something you cannot do with Java  
and stuff). Mostly you wont need to do this, but there are situations  
when it's useful.

            / http://www.scred.com/
            / http://www.fishpool.com/~setok/




More information about the Xotcl mailing list