| 1 |
'\" |
| 2 |
'\" Copyright (c) 2007 Donal K. Fellows |
| 3 |
'\" |
| 4 |
'\" See the file "license.terms" for information on usage and redistribution |
| 5 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 6 |
'\" |
| 7 |
.TH my n 0.1 TclOO "TclOO Commands" |
| 8 |
.so man.macros |
| 9 |
.BS |
| 10 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 11 |
.SH NAME |
| 12 |
my \- invoke any method of current object |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
package require TclOO |
| 16 |
|
| 17 |
\fBmy\fI methodName\fR ?\fIarg ...\fR? |
| 18 |
.fi |
| 19 |
.BE |
| 20 |
.SH DESCRIPTION |
| 21 |
.PP |
| 22 |
The \fBmy\fR command is used to allow methods of objects to invoke any method |
| 23 |
of the object (or its class). In particular, the set of valid values for |
| 24 |
\fImethodName\fR is the set of all methods supported by an object and its |
| 25 |
superclasses, including those that are not exported. The object upon which the |
| 26 |
method is invoked is always the one that is the current context of the method |
| 27 |
(i.e. the object that is returned by \fBself object\fR) from which the |
| 28 |
\fBmy\fR command is invoked. |
| 29 |
.PP |
| 30 |
Each object has its own \fBmy\fR command, contained in its instance namespace. |
| 31 |
.SH EXAMPLES |
| 32 |
.PP |
| 33 |
This example shows basic use of \fBmy\fR to use the \fBvariables\fR method of |
| 34 |
the \fBoo::object\fR class, which is not publicly visible by default: |
| 35 |
.PP |
| 36 |
.CS |
| 37 |
oo::class create c { |
| 38 |
method count {} { |
| 39 |
\fBmy\fR variable counter |
| 40 |
puts [incr counter] |
| 41 |
} |
| 42 |
} |
| 43 |
c create o |
| 44 |
o count \fI\(-> prints "1"\fR |
| 45 |
o count \fI\(-> prints "2"\fR |
| 46 |
o count \fI\(-> prints "3"\fR |
| 47 |
.CE |
| 48 |
.SH "SEE ALSO" |
| 49 |
next(n), oo::object(n), self(n) |
| 50 |
.SH KEYWORDS |
| 51 |
method, method visibility, object, private method, public method |
| 52 |
|
| 53 |
.\" Local variables: |
| 54 |
.\" mode: nroff |
| 55 |
.\" fill-column: 78 |
| 56 |
.\" End: |