'\"
|
'\"
|
'\" Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
'\" Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
'\"
|
'\"
|
'\" See the file "license.terms" for information on usage and redistribution
|
'\" See the file "license.terms" for information on usage and redistribution
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
'\"
|
'\"
|
'\" RCS: $Id: itcl_class.n,v 1.1.1.1 2002-01-16 10:24:46 markom Exp $
|
'\" RCS: $Id: itcl_class.n,v 1.1.1.1 2002-01-16 10:24:46 markom Exp $
|
'\"
|
'\"
|
.so man.macros
|
.so man.macros
|
.TH itcl_class n 3.0 itcl "[incr\ Tcl]"
|
.TH itcl_class n 3.0 itcl "[incr\ Tcl]"
|
.BS
|
.BS
|
'\" Note: do not modify the .SH NAME line immediately below!
|
'\" Note: do not modify the .SH NAME line immediately below!
|
.SH NAME
|
.SH NAME
|
itcl_class \- create a class of objects (obsolete)
|
itcl_class \- create a class of objects (obsolete)
|
.SH SYNOPSIS
|
.SH SYNOPSIS
|
\fBitcl_class \fIclassName\fR \fB{
|
\fBitcl_class \fIclassName\fR \fB{
|
.br
|
.br
|
\fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?
|
\fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?
|
.br
|
.br
|
\fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fR
|
\fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fR
|
.br
|
.br
|
\fBdestructor \fIbody\fR
|
\fBdestructor \fIbody\fR
|
.br
|
.br
|
\fBmethod \fIname args body\fR
|
\fBmethod \fIname args body\fR
|
.br
|
.br
|
\fBproc \fIname args body\fR
|
\fBproc \fIname args body\fR
|
.br
|
.br
|
\fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?
|
\fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?
|
.br
|
.br
|
\fBprotected \fIvarName\fR ?\fIinit\fR?
|
\fBprotected \fIvarName\fR ?\fIinit\fR?
|
.br
|
.br
|
\fBcommon \fIvarName\fR ?\fIinit\fR?
|
\fBcommon \fIvarName\fR ?\fIinit\fR?
|
.br
|
.br
|
\fB}\fR
|
\fB}\fR
|
.sp
|
.sp
|
\fIclassName objName\fR ?\fIargs...\fR?
|
\fIclassName objName\fR ?\fIargs...\fR?
|
.br
|
.br
|
\fIclassName\fR \fB#auto\fR ?\fIargs...\fR?
|
\fIclassName\fR \fB#auto\fR ?\fIargs...\fR?
|
.br
|
.br
|
\fIclassName\fR \fB::\fR \fIproc\fR ?\fIargs...\fR?
|
\fIclassName\fR \fB::\fR \fIproc\fR ?\fIargs...\fR?
|
.sp
|
.sp
|
\fIobjName method\fR ?\fIargs...\fR?
|
\fIobjName method\fR ?\fIargs...\fR?
|
.sp
|
.sp
|
\fICommands available within class methods/procs:\fR
|
\fICommands available within class methods/procs:\fR
|
.br
|
.br
|
\fBglobal \fIvarName\fR ?\fIvarName...\fR?
|
\fBglobal \fIvarName\fR ?\fIvarName...\fR?
|
.br
|
.br
|
\fBprevious \fIcommand\fR ?\fIargs...\fR?
|
\fBprevious \fIcommand\fR ?\fIargs...\fR?
|
.br
|
.br
|
\fBvirtual \fIcommand\fR ?\fIargs...\fR?
|
\fBvirtual \fIcommand\fR ?\fIargs...\fR?
|
.BE
|
.BE
|
|
|
.SH DESCRIPTION
|
.SH DESCRIPTION
|
.PP
|
.PP
|
This command is considered obsolete, but is retained for
|
This command is considered obsolete, but is retained for
|
backward-compatibility with earlier versions of \fB[incr\ Tcl]\fR.
|
backward-compatibility with earlier versions of \fB[incr\ Tcl]\fR.
|
It has been replaced by the \fBclass\fR command, which should
|
It has been replaced by the \fBclass\fR command, which should
|
be used for any new development.
|
be used for any new development.
|
|
|
.TP
|
.TP
|
\fBitcl_class \fIclassName definition\fR
|
\fBitcl_class \fIclassName definition\fR
|
Provides the definition for a class named \fIclassName\fR. If
|
Provides the definition for a class named \fIclassName\fR. If
|
\fIclassName\fR is already defined, then this command returns
|
\fIclassName\fR is already defined, then this command returns
|
an error. If the class definition is successfully parsed,
|
an error. If the class definition is successfully parsed,
|
\fIclassName\fR becomes a command in the current namespace
|
\fIclassName\fR becomes a command in the current namespace
|
context, handling the
|
context, handling the
|
creation of objects and providing access to class scope.
|
creation of objects and providing access to class scope.
|
The class \fIdefinition\fR
|
The class \fIdefinition\fR
|
is evaluated as a series of Tcl statements that define
|
is evaluated as a series of Tcl statements that define
|
elements within the class. In addition to the usual
|
elements within the class. In addition to the usual
|
commands, the following class definition commands are recognized:
|
commands, the following class definition commands are recognized:
|
.RS
|
.RS
|
.TP
|
.TP
|
\fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?
|
\fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?
|
Declares one or more base classes, causing the current class to
|
Declares one or more base classes, causing the current class to
|
inherit their characteristics. Classes must have been defined by
|
inherit their characteristics. Classes must have been defined by
|
a previous \fBitcl_class\fR command, or must be available to the
|
a previous \fBitcl_class\fR command, or must be available to the
|
auto-loading facility (see "AUTO-LOADING" below). A single class
|
auto-loading facility (see "AUTO-LOADING" below). A single class
|
definition can contain no more than one \fBinherit\fR command.
|
definition can contain no more than one \fBinherit\fR command.
|
.RS
|
.RS
|
.LP
|
.LP
|
When the same member name appears in two or more base classes,
|
When the same member name appears in two or more base classes,
|
the base class that appears first in the \fBinherit\fR list takes
|
the base class that appears first in the \fBinherit\fR list takes
|
precedence. For example, if classes "Foo" and "Bar" both contain
|
precedence. For example, if classes "Foo" and "Bar" both contain
|
the member "x", then the "\fBinherit\fR" statement:
|
the member "x", then the "\fBinherit\fR" statement:
|
.CS
|
.CS
|
inherit Foo Bar
|
inherit Foo Bar
|
.CE
|
.CE
|
allows "Foo::x" to be accessed simply as "x" but forces "Bar::x" (and
|
allows "Foo::x" to be accessed simply as "x" but forces "Bar::x" (and
|
all other inherited members named "x") to be referenced with their
|
all other inherited members named "x") to be referenced with their
|
explicit "\fIclass\fR::\fImember\fR" name.
|
explicit "\fIclass\fR::\fImember\fR" name.
|
.RE
|
.RE
|
.TP
|
.TP
|
\fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fR
|
\fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fR
|
Declares the argument list and body used for the constructor, which
|
Declares the argument list and body used for the constructor, which
|
is automatically invoked whenever an object is created. Before
|
is automatically invoked whenever an object is created. Before
|
.VS
|
.VS
|
the \fIbody\fR is executed, the optional \fIinit\fR statement is
|
the \fIbody\fR is executed, the optional \fIinit\fR statement is
|
used to invoke any base class constructors that require arguments.
|
used to invoke any base class constructors that require arguments.
|
Variables in the \fIargs\fR specification can be accessed in the
|
Variables in the \fIargs\fR specification can be accessed in the
|
\fIinit\fR code fragment, and passed to base class constructors.
|
\fIinit\fR code fragment, and passed to base class constructors.
|
After evaluating the \fIinit\fR statement, any base class
|
After evaluating the \fIinit\fR statement, any base class
|
constructors that have not been executed are invoked without
|
constructors that have not been executed are invoked without
|
arguments. This ensures that all base classes are fully
|
arguments. This ensures that all base classes are fully
|
constructed before the constructor \fIbody\fR is executed.
|
constructed before the constructor \fIbody\fR is executed.
|
.VE
|
.VE
|
If construction is successful, the constructor always returns
|
If construction is successful, the constructor always returns
|
the object name\-regardless of how the \fIbody\fR is defined\-and
|
the object name\-regardless of how the \fIbody\fR is defined\-and
|
the object name becomes a command in the current namespace context.
|
the object name becomes a command in the current namespace context.
|
If construction fails, an error message is returned.
|
If construction fails, an error message is returned.
|
.TP
|
.TP
|
\fBdestructor \fIbody\fR
|
\fBdestructor \fIbody\fR
|
Declares the body used for the destructor, which is automatically invoked
|
Declares the body used for the destructor, which is automatically invoked
|
whenever an object is deleted. If the destructor is successful, the object
|
whenever an object is deleted. If the destructor is successful, the object
|
data is destroyed and the object name is removed as a command from the
|
data is destroyed and the object name is removed as a command from the
|
interpreter. If destruction fails, an error message is returned
|
interpreter. If destruction fails, an error message is returned
|
and the object remains.
|
and the object remains.
|
.RS
|
.RS
|
.LP
|
.LP
|
.VS
|
.VS
|
When an object is destroyed, all destructors in a class hierarchy
|
When an object is destroyed, all destructors in a class hierarchy
|
are invoked in order from most- to least-specific. This is the
|
are invoked in order from most- to least-specific. This is the
|
order that the classes are reported by the "\fBinfo heritage\fR"
|
order that the classes are reported by the "\fBinfo heritage\fR"
|
command, and it is exactly the opposite of the default constructor
|
command, and it is exactly the opposite of the default constructor
|
order.
|
order.
|
.VE
|
.VE
|
.RE
|
.RE
|
.TP
|
.TP
|
\fBmethod \fIname args body\fR
|
\fBmethod \fIname args body\fR
|
Declares a method called \fIname\fR with an argument list \fIargs\fR
|
Declares a method called \fIname\fR with an argument list \fIargs\fR
|
and a \fIbody\fR of Tcl statements. A method is just like the usual
|
and a \fIbody\fR of Tcl statements. A method is just like the usual
|
Tcl "proc" except that it has transparent access to
|
Tcl "proc" except that it has transparent access to
|
.VS
|
.VS
|
object-specific variables, as well as
|
object-specific variables, as well as
|
.VE
|
.VE
|
common variables. Within the class scope, a method can be invoked
|
common variables. Within the class scope, a method can be invoked
|
like any other command\-simply by using its name. Outside of the
|
like any other command\-simply by using its name. Outside of the
|
class scope, the method name must be prefaced by an object
|
class scope, the method name must be prefaced by an object
|
name. Methods in a base class that are redefined in the current class
|
name. Methods in a base class that are redefined in the current class
|
or hidden by another base class can be explicitly scoped using the
|
or hidden by another base class can be explicitly scoped using the
|
"\fIclass\fR::\fImethod\fR" syntax.
|
"\fIclass\fR::\fImethod\fR" syntax.
|
.TP
|
.TP
|
\fBproc \fIname args body\fR
|
\fBproc \fIname args body\fR
|
Declares a proc called \fIname\fR with an argument list \fIargs\fR
|
Declares a proc called \fIname\fR with an argument list \fIargs\fR
|
and a \fIbody\fR of Tcl statements. A proc is similar to a method,
|
and a \fIbody\fR of Tcl statements. A proc is similar to a method,
|
except that it can be invoked without referring to a specific object,
|
except that it can be invoked without referring to a specific object,
|
and therefore has access only to common variables\-not
|
and therefore has access only to common variables\-not
|
.VS
|
.VS
|
to object-specific variables declared with the \fBpublic\fR
|
to object-specific variables declared with the \fBpublic\fR
|
and \fBprotected\fR commands.
|
and \fBprotected\fR commands.
|
.VE
|
.VE
|
Within the class scope, a proc can be invoked
|
Within the class scope, a proc can be invoked
|
like any other command\-simply by using its name. In any other
|
like any other command\-simply by using its name. In any other
|
namespace context, the proc is invoked using a qualified name
|
namespace context, the proc is invoked using a qualified name
|
like "\fIclassName\fB::\fIproc\fR".
|
like "\fIclassName\fB::\fIproc\fR".
|
Procs in a base class that are redefined in the current
|
Procs in a base class that are redefined in the current
|
class, or hidden by another base class, can also be accessed
|
class, or hidden by another base class, can also be accessed
|
via their qualified name.
|
via their qualified name.
|
.TP
|
.TP
|
\fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?
|
\fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?
|
Declares a public variable named \fIvarName\fR. Public variables are
|
Declares a public variable named \fIvarName\fR. Public variables are
|
visible in methods within the scope of their class and any derived class.
|
visible in methods within the scope of their class and any derived class.
|
In addition, they can be modified outside of the class scope using the special
|
In addition, they can be modified outside of the class scope using the special
|
"config" formal argument (see "ARGUMENT LISTS" above). If the optional
|
"config" formal argument (see "ARGUMENT LISTS" above). If the optional
|
\fIinit\fR is specified, it is used as the initial value of the variable
|
\fIinit\fR is specified, it is used as the initial value of the variable
|
when a new object is created. If the optional \fIconfig\fR command
|
when a new object is created. If the optional \fIconfig\fR command
|
is specified,
|
is specified,
|
it is invoked whenever a public variable is modified via the "config"
|
it is invoked whenever a public variable is modified via the "config"
|
formal argument; if the \fIconfig\fR command returns an error, the
|
formal argument; if the \fIconfig\fR command returns an error, the
|
public variable is reset to its value before configuration, and the
|
public variable is reset to its value before configuration, and the
|
method handling the configuration returns an error.
|
method handling the configuration returns an error.
|
.TP
|
.TP
|
\fBprotected \fIvarName\fR ?\fIinit\fR?
|
\fBprotected \fIvarName\fR ?\fIinit\fR?
|
Declares a protected variable named \fIvarName\fR. Protected variables
|
Declares a protected variable named \fIvarName\fR. Protected variables
|
are visible in methods within the scope of their class and any derived class,
|
are visible in methods within the scope of their class and any derived class,
|
but cannot
|
but cannot
|
be modified outside of the class scope. If the optional \fIinit\fR
|
be modified outside of the class scope. If the optional \fIinit\fR
|
is specified, it is used as the initial value of the variable when a new
|
is specified, it is used as the initial value of the variable when a new
|
object is created. Initialization forces the variable to be a simple
|
object is created. Initialization forces the variable to be a simple
|
scalar value; uninitialized variables, on the other hand, can be used
|
scalar value; uninitialized variables, on the other hand, can be used
|
as arrays. All objects have a built-in protected variable named
|
as arrays. All objects have a built-in protected variable named
|
"this" which is initialized to the instance name for the object.
|
"this" which is initialized to the instance name for the object.
|
.TP
|
.TP
|
\fBcommon \fIvarName\fR ?\fIinit\fR?
|
\fBcommon \fIvarName\fR ?\fIinit\fR?
|
Declares a common variable named \fIvarName\fR. Common variables are
|
Declares a common variable named \fIvarName\fR. Common variables are
|
shared among all objects in a class. They are visible in methods and
|
shared among all objects in a class. They are visible in methods and
|
procs in the scope of their class and any derived class, but cannot be
|
procs in the scope of their class and any derived class, but cannot be
|
modified outside of the class scope.
|
modified outside of the class scope.
|
If the optional \fIinit\fR is specified, it is used as the
|
If the optional \fIinit\fR is specified, it is used as the
|
initial value of the variable. Initialization forces the variable to be
|
initial value of the variable. Initialization forces the variable to be
|
a simple scalar value; uninitialized variables, on the other hand, can
|
a simple scalar value; uninitialized variables, on the other hand, can
|
be used as arrays.
|
be used as arrays.
|
.RS
|
.RS
|
.LP
|
.LP
|
Once a common variable has been declared, it can be configured using
|
Once a common variable has been declared, it can be configured using
|
ordinary Tcl code within the class definition. This facility is
|
ordinary Tcl code within the class definition. This facility is
|
particularly useful when the initialization of the variable is
|
particularly useful when the initialization of the variable is
|
non-trivial\-when the variable contains an array of values, for example:
|
non-trivial\-when the variable contains an array of values, for example:
|
.CS
|
.CS
|
itcl_class Foo {
|
itcl_class Foo {
|
.
|
.
|
.
|
.
|
common boolean
|
common boolean
|
set boolean(true) 1
|
set boolean(true) 1
|
set boolean(false) 0
|
set boolean(false) 0
|
}
|
}
|
.CE
|
.CE
|
.RE
|
.RE
|
.RE
|
.RE
|
|
|
.SH CLASS USAGE
|
.SH CLASS USAGE
|
.PP
|
.PP
|
When a class definition has been loaded (or made available to the
|
When a class definition has been loaded (or made available to the
|
auto-loader), the class name can be used as a command.
|
auto-loader), the class name can be used as a command.
|
.TP
|
.TP
|
\fIclassName objName\fR ?\fIargs...\fR?
|
\fIclassName objName\fR ?\fIargs...\fR?
|
Creates a new object in class \fIclassName\fR with the name \fIobjName\fR.
|
Creates a new object in class \fIclassName\fR with the name \fIobjName\fR.
|
Remaining arguments are passed to the constructor. If construction is
|
Remaining arguments are passed to the constructor. If construction is
|
successful, the object name is returned and this name becomes a command
|
successful, the object name is returned and this name becomes a command
|
in the current namespace context. Otherwise, an error is returned.
|
in the current namespace context. Otherwise, an error is returned.
|
.TP
|
.TP
|
\fIclassName\fR #auto ?\fIargs...\fR?
|
\fIclassName\fR #auto ?\fIargs...\fR?
|
Creates a new object in class \fIclassName\fR with an automatically
|
Creates a new object in class \fIclassName\fR with an automatically
|
generated name. Names are of the form \fIclassName\fR,
|
generated name. Names are of the form \fIclassName\fR,
|
.VS
|
.VS
|
where the \fIclassName\fR part is modified to start with a lowercase
|
where the \fIclassName\fR part is modified to start with a lowercase
|
letter. In class "Toaster", for example, the "\fB#auto\fR" specification
|
letter. In class "Toaster", for example, the "\fB#auto\fR" specification
|
would produce names toaster0, toaster1, etc. Remaining arguments are
|
would produce names toaster0, toaster1, etc. Remaining arguments are
|
.VE
|
.VE
|
passed to the constructor. If construction is successful, the object
|
passed to the constructor. If construction is successful, the object
|
name is returned and this name becomes a command in the current
|
name is returned and this name becomes a command in the current
|
namespace context. Otherwise, an error is returned.
|
namespace context. Otherwise, an error is returned.
|
.TP
|
.TP
|
\fIclassName\fR :: \fIproc\fR ?\fIargs...\fR?
|
\fIclassName\fR :: \fIproc\fR ?\fIargs...\fR?
|
Used outside of the class scope to invoke a class proc named \fIproc\fR.
|
Used outside of the class scope to invoke a class proc named \fIproc\fR.
|
Class procs are like ordinary Tcl procs, except that they are executed
|
Class procs are like ordinary Tcl procs, except that they are executed
|
in the scope of the class and therefore have transparent
|
in the scope of the class and therefore have transparent
|
access to common data members.
|
access to common data members.
|
.RS
|
.RS
|
.LP
|
.LP
|
.VS
|
.VS
|
Notice that, unlike any other scope qualifier in \fB[incr\ Tcl]\fR, the "::"
|
Notice that, unlike any other scope qualifier in \fB[incr\ Tcl]\fR, the "::"
|
shown above is surrounded by spaces. This is unnecessary with the
|
shown above is surrounded by spaces. This is unnecessary with the
|
new namespace facility, and is considered obsolete. The capability
|
new namespace facility, and is considered obsolete. The capability
|
is still supported, however, to provide backward-compatibility with
|
is still supported, however, to provide backward-compatibility with
|
earlier versions.
|
earlier versions.
|
.VE
|
.VE
|
.RE
|
.RE
|
|
|
.SH OBJECT USAGE
|
.SH OBJECT USAGE
|
.TP
|
.TP
|
\fIobjName method\fR ?\fIargs...\fR?
|
\fIobjName method\fR ?\fIargs...\fR?
|
Invokes a method named \fImethod\fR to operate on the specified object.
|
Invokes a method named \fImethod\fR to operate on the specified object.
|
Remaining arguments are passed to the method. The method name can
|
Remaining arguments are passed to the method. The method name can
|
be "constructor", "destructor", any method name appearing in the
|
be "constructor", "destructor", any method name appearing in the
|
class definition, or any of the following built-in methods.
|
class definition, or any of the following built-in methods.
|
.SH BUILT-IN METHODS
|
.SH BUILT-IN METHODS
|
.TP
|
.TP
|
\fIobjName\fR \fBisa \fIclassName\fR
|
\fIobjName\fR \fBisa \fIclassName\fR
|
Returns non-zero if the given \fIclassName\fR can be found in the
|
Returns non-zero if the given \fIclassName\fR can be found in the
|
object's heritage, and zero otherwise.
|
object's heritage, and zero otherwise.
|
.TP
|
.TP
|
\fIobjName\fR \fBdelete\fR
|
\fIobjName\fR \fBdelete\fR
|
Invokes the destructor associated with an object.
|
Invokes the destructor associated with an object.
|
If the destructor is successful, data associated with the object is
|
If the destructor is successful, data associated with the object is
|
deleted and \fIobjName\fR is removed as a command from the
|
deleted and \fIobjName\fR is removed as a command from the
|
interpreter. Returns the empty string, regardless of the destructor
|
interpreter. Returns the empty string, regardless of the destructor
|
body.
|
body.
|
.RS
|
.RS
|
.LP
|
.LP
|
.VS
|
.VS
|
The built-in \fBdelete\fR method has been replaced by the
|
The built-in \fBdelete\fR method has been replaced by the
|
"\fBdelete object\fR" command in the global namespace, and
|
"\fBdelete object\fR" command in the global namespace, and
|
is considered obsolete. The capability is still supported,
|
is considered obsolete. The capability is still supported,
|
however, to provide backward-compatibility with earlier versions.
|
however, to provide backward-compatibility with earlier versions.
|
.VE
|
.VE
|
.RE
|
.RE
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo \fIoption\fR ?\fIargs...\fR?
|
\fIobjName\fR \fBinfo \fIoption\fR ?\fIargs...\fR?
|
Returns information related to the class definition or to
|
Returns information related to the class definition or to
|
a particular object named \fIobjName\fR.
|
a particular object named \fIobjName\fR.
|
The \fIoption\fR parameter includes the following things, as well as
|
The \fIoption\fR parameter includes the following things, as well as
|
the options recognized by the usual Tcl "info" command:
|
the options recognized by the usual Tcl "info" command:
|
.RS
|
.RS
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo class\fR
|
\fIobjName\fR \fBinfo class\fR
|
.VS
|
.VS
|
Returns the name of the most-specific class for object \fIobjName\fR.
|
Returns the name of the most-specific class for object \fIobjName\fR.
|
.VE
|
.VE
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo inherit\fR
|
\fIobjName\fR \fBinfo inherit\fR
|
Returns the list of base classes as they were defined in the
|
Returns the list of base classes as they were defined in the
|
"\fBinherit\fR" command, or an empty string if this class
|
"\fBinherit\fR" command, or an empty string if this class
|
has no base classes.
|
has no base classes.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo heritage\fR
|
\fIobjName\fR \fBinfo heritage\fR
|
Returns the current class name and the entire list of base classes in
|
Returns the current class name and the entire list of base classes in
|
the order that they are traversed for member lookup and object
|
the order that they are traversed for member lookup and object
|
destruction.
|
destruction.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo method\fR ?\fImethodName\fR? ?\fB-args\fR? ?\fB-body\fR?
|
\fIobjName\fR \fBinfo method\fR ?\fImethodName\fR? ?\fB-args\fR? ?\fB-body\fR?
|
With no arguments, this command returns a list of all class methods.
|
With no arguments, this command returns a list of all class methods.
|
If \fImethodName\fR is specified, it returns information for a specific method.
|
If \fImethodName\fR is specified, it returns information for a specific method.
|
If neither of the optional \fB-args\fR or \fB-body\fR flags is specified,
|
If neither of the optional \fB-args\fR or \fB-body\fR flags is specified,
|
a complete method definition is returned as a list of three elements
|
a complete method definition is returned as a list of three elements
|
including the method name, argument list and body. Otherwise, the
|
including the method name, argument list and body. Otherwise, the
|
requested information is returned without the method name.
|
requested information is returned without the method name.
|
If the \fImethodName\fR is not recognized, an empty string is returned.
|
If the \fImethodName\fR is not recognized, an empty string is returned.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo proc\fR ?\fIprocName\fR? ?\fB-args\fR? ?\fB-body\fR?
|
\fIobjName\fR \fBinfo proc\fR ?\fIprocName\fR? ?\fB-args\fR? ?\fB-body\fR?
|
With no arguments, this command returns a list of all class procs.
|
With no arguments, this command returns a list of all class procs.
|
If \fIprocName\fR is specified, it returns information for a specific proc.
|
If \fIprocName\fR is specified, it returns information for a specific proc.
|
If neither of the optional \fB-args\fR or \fB-body\fR flags is specified,
|
If neither of the optional \fB-args\fR or \fB-body\fR flags is specified,
|
a complete proc definition is returned as a list of three elements
|
a complete proc definition is returned as a list of three elements
|
including the proc name, argument list and body. Otherwise, the
|
including the proc name, argument list and body. Otherwise, the
|
requested information is returned without the proc name.
|
requested information is returned without the proc name.
|
If the \fIprocName\fR is not recognized, an empty string is returned.
|
If the \fIprocName\fR is not recognized, an empty string is returned.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo public\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR? ?\fB-config\fR?
|
\fIobjName\fR \fBinfo public\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR? ?\fB-config\fR?
|
With no arguments, this command returns a list of all public variables.
|
With no arguments, this command returns a list of all public variables.
|
If \fIvarName\fR is specified, it returns information for a specific public
|
If \fIvarName\fR is specified, it returns information for a specific public
|
variable.
|
variable.
|
If none of the optional \fB-init\fR, \fB-value\fR or \fB-config\fR flags
|
If none of the optional \fB-init\fR, \fB-value\fR or \fB-config\fR flags
|
are specified, all available information is returned as a list of four
|
are specified, all available information is returned as a list of four
|
elements including the variable name, initial value, current value,
|
elements including the variable name, initial value, current value,
|
and configuration commands. Otherwise, the requested information is
|
and configuration commands. Otherwise, the requested information is
|
returned without the variable name.
|
returned without the variable name.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo protected\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR?
|
\fIobjName\fR \fBinfo protected\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR?
|
With no arguments, this command returns a list of all protected variables.
|
With no arguments, this command returns a list of all protected variables.
|
If \fIvarName\fR is specified, it returns information for a specific protected
|
If \fIvarName\fR is specified, it returns information for a specific protected
|
variable.
|
variable.
|
If neither of the optional \fB-init\fR or \fB-value\fR flags is specified,
|
If neither of the optional \fB-init\fR or \fB-value\fR flags is specified,
|
all available information is returned as a list of three elements
|
all available information is returned as a list of three elements
|
including the variable name, initial value and current value.
|
including the variable name, initial value and current value.
|
Otherwise, the requested information is returned without the variable name.
|
Otherwise, the requested information is returned without the variable name.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
.TP
|
.TP
|
\fIobjName\fR \fBinfo common\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR?
|
\fIobjName\fR \fBinfo common\fR ?\fIvarName\fR? ?\fB-init\fR? ?\fB-value\fR?
|
With no arguments, this command returns a list of all common variables.
|
With no arguments, this command returns a list of all common variables.
|
If \fIvarName\fR is specified, it returns information for a specific common
|
If \fIvarName\fR is specified, it returns information for a specific common
|
variable.
|
variable.
|
If neither of the optional \fB-init\fR or \fB-value\fR flags is specified,
|
If neither of the optional \fB-init\fR or \fB-value\fR flags is specified,
|
all available information is returned as a list of three elements
|
all available information is returned as a list of three elements
|
including the variable name, initial value and current value.
|
including the variable name, initial value and current value.
|
Otherwise, the requested information is returned without the variable name.
|
Otherwise, the requested information is returned without the variable name.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
If the \fIvarName\fR is not recognized, an empty string is returned.
|
.RE
|
.RE
|
.SH OTHER BUILT-IN COMMANDS
|
.SH OTHER BUILT-IN COMMANDS
|
The following commands are also available within the scope of each class.
|
The following commands are also available within the scope of each class.
|
They cannot be accessed from outside of the class as proper methods or
|
They cannot be accessed from outside of the class as proper methods or
|
procs; rather, they are useful inside the class when implementing its
|
procs; rather, they are useful inside the class when implementing its
|
functionality.
|
functionality.
|
.TP
|
.TP
|
\fBglobal \fIvarName\fR ?\fIvarName...\fR?
|
\fBglobal \fIvarName\fR ?\fIvarName...\fR?
|
Creates a link to one or more global variables in the current
|
Creates a link to one or more global variables in the current
|
namespace context. Global variables can also be accessed in
|
namespace context. Global variables can also be accessed in
|
other namespaces by including namespace qualifiers in \fIvarName\fR.
|
other namespaces by including namespace qualifiers in \fIvarName\fR.
|
This is useful when communicating with Tk widgets that rely on global
|
This is useful when communicating with Tk widgets that rely on global
|
variables.
|
variables.
|
.TP
|
.TP
|
\fBprevious \fIcommand\fR ?\fIargs...\fR?
|
\fBprevious \fIcommand\fR ?\fIargs...\fR?
|
Invokes \fIcommand\fR in the scope of the most immediate base class
|
Invokes \fIcommand\fR in the scope of the most immediate base class
|
.VS
|
.VS
|
(i.e., the "previous" class) for the object. For classes using single
|
(i.e., the "previous" class) for the object. For classes using single
|
.VE
|
.VE
|
inheritance, this facility can be used to avoid hard-wired base class
|
inheritance, this facility can be used to avoid hard-wired base class
|
references of the form "\fIclass\fR::\fIcommand\fR", making code easier
|
references of the form "\fIclass\fR::\fIcommand\fR", making code easier
|
to maintain. For classes using multiple inheritance, the utility of
|
to maintain. For classes using multiple inheritance, the utility of
|
this function is dubious.
|
this function is dubious.
|
If the class at the relevant scope has no base class, an error is returned.
|
If the class at the relevant scope has no base class, an error is returned.
|
.TP
|
.TP
|
\fBvirtual \fIcommand\fR ?\fIargs...\fR?
|
\fBvirtual \fIcommand\fR ?\fIargs...\fR?
|
.VS
|
.VS
|
Invokes \fIcommand\fR in the scope of the most-specific class for the
|
Invokes \fIcommand\fR in the scope of the most-specific class for the
|
object. The methods within a class are automatically virtual; whenever
|
object. The methods within a class are automatically virtual; whenever
|
an unqualified method name is used, it always refers to the most-specific
|
an unqualified method name is used, it always refers to the most-specific
|
implementation for that method. This function provides a way of
|
implementation for that method. This function provides a way of
|
evaluating code fragments in a base class that have access to the
|
evaluating code fragments in a base class that have access to the
|
most-specific object information. It is useful, for example, for
|
most-specific object information. It is useful, for example, for
|
creating base classes that can capture and save an object's state.
|
creating base classes that can capture and save an object's state.
|
It inverts the usual notions of object-oriented programming, however,
|
It inverts the usual notions of object-oriented programming, however,
|
and should therefore be used sparingly.
|
and should therefore be used sparingly.
|
.VE
|
.VE
|
|
|
.SH AUTO-LOADING
|
.SH AUTO-LOADING
|
.PP
|
.PP
|
Class definitions need not be loaded explicitly; they can be loaded as
|
Class definitions need not be loaded explicitly; they can be loaded as
|
needed by the usual Tcl auto-loading facility. Each directory containing
|
needed by the usual Tcl auto-loading facility. Each directory containing
|
class definition files should have an accompanying "tclIndex" file.
|
class definition files should have an accompanying "tclIndex" file.
|
Each line in this file identifies a Tcl procedure or \fB[incr\ Tcl]\fR
|
Each line in this file identifies a Tcl procedure or \fB[incr\ Tcl]\fR
|
class definition and the file where the definition can be found.
|
class definition and the file where the definition can be found.
|
.PP
|
.PP
|
For example, suppose a directory contains the definitions for classes
|
For example, suppose a directory contains the definitions for classes
|
"Toaster" and "SmartToaster". Then the "tclIndex" file for this
|
"Toaster" and "SmartToaster". Then the "tclIndex" file for this
|
directory would look like:
|
directory would look like:
|
.CS
|
.CS
|
# Tcl autoload index file, version 2.0 for [incr Tcl]
|
# Tcl autoload index file, version 2.0 for [incr Tcl]
|
# This file is generated by the "auto_mkindex" command
|
# This file is generated by the "auto_mkindex" command
|
# and sourced to set up indexing information for one or
|
# and sourced to set up indexing information for one or
|
# more commands. Typically each line is a command that
|
# more commands. Typically each line is a command that
|
# sets an element in the auto_index array, where the
|
# sets an element in the auto_index array, where the
|
# element name is the name of a command and the value is
|
# element name is the name of a command and the value is
|
# a script that loads the command.
|
# a script that loads the command.
|
|
|
set auto_index(::Toaster) "source $dir/Toaster.itcl"
|
set auto_index(::Toaster) "source $dir/Toaster.itcl"
|
set auto_index(::SmartToaster) "source $dir/SmartToaster.itcl"
|
set auto_index(::SmartToaster) "source $dir/SmartToaster.itcl"
|
.PP
|
.PP
|
The \fBauto_mkindex\fR command is used to automatically
|
The \fBauto_mkindex\fR command is used to automatically
|
generate "tclIndex" files.
|
generate "tclIndex" files.
|
.CE
|
.CE
|
The auto-loader must be made aware of this directory by appending
|
The auto-loader must be made aware of this directory by appending
|
the directory name to the "auto_path" variable. When this is in
|
the directory name to the "auto_path" variable. When this is in
|
place, classes will be auto-loaded as needed when used in an
|
place, classes will be auto-loaded as needed when used in an
|
application.
|
application.
|
|
|
.SH KEYWORDS
|
.SH KEYWORDS
|
class, object, object-oriented
|
class, object, object-oriented
|
|
|