<h1>oo::object</h1>
<DL style="font-size:.85em">
<DD><A HREF="#M2" NAME="L1271">NAME</A>
<DL><DD>oo::object &mdash; root class of the class
<DD><A HREF="#M3" NAME="L1272">SYNOPSIS</A>
<DL>
</DL>
<DD><A HREF="#M4" NAME="L1273">CLASS HIERARCHY</A>
<DD><A HREF="#M5" NAME="L1274">DESCRIPTION</A>
<DD><A HREF="#M6" NAME="L1275">CONSTRUCTOR</A>
<DD><A HREF="#M7" NAME="L1276">DESTRUCTOR</A>
<DD><A HREF="#M8" NAME="L1277">EXPORTED METHODS</A>
<DL class="exported methods">
<DD><A HREF="#M9" NAME="L1278"><I>obj
</DL>
<DD><A HREF="#M10" NAME="L1279">NON-EXPORTED METHODS</A>
<DL class="non-exported methods">
<DD><A HREF="#M11" NAME="L1280"><I>obj ?<I>arg
<DD><A HREF="#M12" NAME="L1281"><I>obj </I><B>unknown ?<I>arg
<DD><A HREF="#M13" NAME="L1282"><I>obj </I><B>variable </B>?<I>varName
<DD><A HREF="#M14" NAME="L1283"><I>obj </I><B>varname
<DD><A HREF="#M15" NAME="L1284"><I>obj </I><B>&lt;cloned&gt;
</DL>
<DD><A HREF="#M16" NAME="L1285">EXAMPLES</A>
<DD><A HREF="#M17" NAME="L1286">SEE ALSO</A>
<DD><A HREF="#M18" NAME="L1287">KEYWORDS</A>
</DL>
<H3><A
oo::object &mdash; root class of the class hierarchy
<H3><A
package require TclOO<BR>
<BR>
<B>oo::object</B><I> method </I>?<I>arg ...</I>?<BR>
<H3><A NAME="M4">CLASS
<B>oo::object</B><BR>
<H3><A
The <B>oo::object</B> class is the root class of the object hierarchy; every
object is an instance of this class. Since classes are themselves objects,
they are instances of this class too. Objects are always referred to by their
name, and may be <B>rename</B>d while maintaining their identity.
<P>
Instances of objects may be made with either the <B>create</B> or <B>new</B>
methods of the <B>oo::object</B> object itself, or by invoking those methods on
any of the subclass objects; see <B><A for more details. The
configuration of individual objects (i.e., instance-specific methods, mixed-in
classes, etc.) may be controlled with the <B><A command.
<P>
Each object has a unique namespace associated with it, the instance namespace.
This namespace holds all the instance variables of the object, and will be the
current namespace whenever a method of the object is invoked (including a
method of the class of the object). When the object is destroyed, its instance
namespace is deleted. The instance namespace contains the object's <B><A
command, which may be used to invoke non-exported methods of the object or to
create a reference to the object for the purpose of invocation which persists
across renamings of the object.
<H4><A
The <B>oo::object</B> class does not define an explicit constructor.
<H4><A
The <B>oo::object</B> class does not define an explicit destructor.
<H4><A NAME="M8">EXPORTED
The <B>oo::object</B> class supports the following exported methods:
<P>
<DL class="exported methods">
<DT><A NAME="M9"><I>obj
This method destroys the object, <I>obj</I>, that it is invoked upon, invoking
any destructors on the object's class in the process. It is equivalent to
using <B>rename</B> to delete the object command. The result of this method is
always the empty string.
<P></DL>
<H4><A NAME="M10">NON-EXPORTED
The <B>oo::object</B> class supports the following non-exported methods:
<P>
<DL class="non-exported methods">
<DT><A NAME="M11"><I>obj ?<I>arg
This method concatenates the arguments, <I>arg</I>, as if with <B>concat</B>,
and then evaluates the resulting script in the namespace that is uniquely
associated with <I>obj</I>, returning the result of the evaluation.
<P><DT><A NAME="M12"><I>obj </I><B>unknown ?<I>arg
This method is called when an attempt to invoke the method <I>methodName</I> on
object <I>obj</I> fails. The arguments that the user supplied to the method are
given as <I>arg</I> arguments.
If <I>methodName</I> is absent, the object was invoked with no method name at
all (or any other arguments).
The default implementation (i.e., the one defined by the <B>oo::object</B>
class) generates a suitable error, detailing what methods the object supports
given whether the object was invoked by its public name or through the
<B><A command.
<P><DT><A NAME="M13"><I>obj </I><B>variable </B>?<I>varName
This method arranges for each variable called <I>varName</I> to be linked from
the object <I>obj</I>'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 <I>varName</I> argument
must not have any namespace separators in it. The result is the empty string.
<P><DT><A NAME="M14"><I>obj </I><B>varname
This method returns the globally qualified name of the variable <I>varName</I>
in the unique namespace for the object <I>obj</I>.
<P><DT><A NAME="M15"><I>obj </I><B>&lt;cloned&gt;
This method is used by the <B>oo::object</B> command to copy the state of one
object to another. It is responsible for copying the procedures and variables
of the namespace of the source object (<I>sourceObjectName</I>) to the current
object. It does not copy any other types of commands or any traces on the
variables; that can be added if desired by overriding this method in a
subclass.
<P></DL>
<H3><A
This example demonstrates basic use of an object.
<P>
<PRE>set obj [<B>oo::object</B> new]
$obj foo             <I><font size="+1">&#8594;</font> error &quot;unknown method foo&quot;</I>
oo::objdefine $obj method foo {} {
    my <B>variable</B> count
    puts &quot;bar[incr count]&quot;
}
$obj foo             <I><font size="+1">&#8594;</font> prints &quot;bar1&quot;</I>
$obj foo             <I><font size="+1">&#8594;</font> prints &quot;bar2&quot;</I>
$obj variable count  <I><font size="+1">&#8594;</font> error &quot;unknown method variable&quot;</I>
$obj <B>destroy</B>
$obj foo             <I><font size="+1">&#8594;</font> error &quot;unknown command
<H3><A NAME="M17">SEE
<B><A <B><A
<H3><A
base class, class, object, root class