TclOO Package

Artifact [e303c1e55f]
Login

Artifact e303c1e55f07a8d99e7e3bbfe9c816efb7d98ffd:

Wiki page [Doc: my] by dkf 2016-09-17 11:10:48.
D 2016-09-17T11:10:48.263
L Doc:\smy
N text/x-markdown
U dkf
W 1760
<h1>my</h1>
<H3><A NAME="M2">NAME</A></H3>
<b>my</b> &mdash; invoke any method of current object
<H3><A NAME="M3">SYNOPSIS</A></H3>
package require TclOO<BR>
<BR>
<B>my</B><I> methodName</I> ?<I>arg ...</I>?<BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
The <B>my</B> command is used to allow methods of objects to invoke any method
of the object (or its class). In particular, the set of valid values for
<I>methodName</I> is the set of all methods supported by an object and its
superclasses, including those that are not exported. The object upon which the
method is invoked is always the one that is the current context of the method
(i.e. the object that is returned by <B><A HREF="?name=Doc:+self">self object</A></B>) from which the
<B>my</B> command is invoked.
<P>
Each object has its own <B>my</B> command, contained in its instance namespace.
<H3><A NAME="M5">EXAMPLES</A></H3>
This example shows basic use of <B>my</B> to use the <B>variables</B> method of
the <B><A HREF="?name=Doc:+oo::object">oo::object</A></B> class, which is not publicly visible by default:
<P>
<PRE>oo::class create c {
    method count {} {
        <B>my</B> variable counter
        puts [incr counter]
    }
}
c create o
o count              <I><font size="+1">&#8594;</font> prints &quot;1&quot;</I>
o count              <I><font size="+1">&#8594;</font> prints &quot;2&quot;</I>
o count              <I><font size="+1">&#8594;</font> prints &quot;3&quot;</I></PRE>
<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="?name=Doc:+next">next</A></B>, <B><A HREF="?name=Doc:+oo::object">oo::object</A></B>, <B><A HREF="?name=Doc:+self">self</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
method, method visibility, object, private method, public method
Z 8784ddc0bbbb6790981765d4b16a11bc