object(n) TclOO Commands object(n)______________________________________________________________________________NAMEoo::object - root class of the class hierarchy
SYNOPSIS
package require TclOO
oo::object method ?arg ...?
CLASS HIERARCHYoo::object_________________________________________________________________DESCRIPTION
The oo::object class is the root class of the object hierarchy; every
object (and hence every class) is an instance of this class. Objects
are always referred to by their name, and may be renamed while main‐
taining their identity. Each object has a unique namespace associated
with it. Instances of objects may be made with either the create or
new methods of the oo::object object itself, or by invoking those meth‐
ods on any of the subclass objects; see oo::class for more details.
CONSTRUCTOR
The oo::object class does not define an explicit constructor.
DESTRUCTOR
The oo::object class does not define an explicit destructor.
EXPORTED METHODS
The oo::object class supports the following exported methods:
obj destroy
This method destroys the object, obj, that it is invoked upon,
invoking any destructors on the object's class in the process.
It is equivalent to using rename to delete the object command.
The result of this method is always the empty string.
NON-EXPORTED METHODS
The oo::object class supports the following non-exported methods:
obj eval ?arg ...?
This method concatenates the arguments, arg, as if with concat,
and then evaluates the resulting script in the namespace that is
uniquely associated with obj, returning the result of the evalu‐
ation.
obj unknown methodName ?arg ...?
This method is called when an attempt to invoke the method
methodName on object obj fails. The arguments that the user sup‐
plied to the method are given as arg argments. The default
implementation (i.e. the one defined by the oo::object class)
generates a suitable error, detailing what methods the object
supports given whether the object was invoked by its public name
or through the my command.
obj variable ?varName ...?
This method arranges for each variable called varName to be
linked from the object obj's unique namespace into the caller's
context. Thus, if it is invoked from inside a procedure then the
namespace variable in the object is linked to the local variable
in the procedure. Each varName argument must not have any names‐
pace separators in it. The result is the empty string.
obj varname varName
This method returns the globally qualified name of the variable
varName in the unique namespace for the object obj.
EXAMPLES
This example demonstrates basic use of an object.
set obj [oo::object new]
$obj foo → error "unknown method foo"
oo::objdefine $obj method foo {} {
my variable count
puts "bar[incr count]"
}
$obj foo → prints "bar1"
$obj foo → prints "bar2"
$obj variable count → error "unknown method variable"
$obj destroy
$obj foo → error "unknown command obj"
SEE ALSOmy(n), oo::class(n)KEYWORDS
base class, class, object, root class
TclOO 0.1 object(n)