⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itcl_class.n

📁 这是一个Linux下的集成开发环境
💻 N
📖 第 1 页 / 共 2 页
字号:
'\"'\" Copyright (c) 1993-1998  Lucent Technologies, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\"'\" RCS: $Id: itcl_class.n,v 1.1 2003/02/05 10:53:53 mdejong Exp $'\".so man.macros.TH itcl_class n 3.0 itcl "[incr\ Tcl]".BS'\" Note:  do not modify the .SH NAME line immediately below!.SH NAMEitcl_class \- create a class of objects (obsolete).SH SYNOPSIS\fBitcl_class \fIclassName\fR \fB{.br    \fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?.br    \fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fR.br    \fBdestructor \fIbody\fR.br    \fBmethod \fIname args body\fR.br    \fBproc \fIname args body\fR.br    \fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?.br    \fBprotected \fIvarName\fR ?\fIinit\fR?.br    \fBcommon \fIvarName\fR ?\fIinit\fR?.br\fB}\fR.sp\fIclassName objName\fR ?\fIargs...\fR?.br\fIclassName\fR \fB#auto\fR ?\fIargs...\fR?.br\fIclassName\fR \fB::\fR \fIproc\fR ?\fIargs...\fR?.sp\fIobjName method\fR ?\fIargs...\fR?.sp\fICommands available within class methods/procs:\fR.br\fBglobal \fIvarName\fR ?\fIvarName...\fR?.br\fBprevious \fIcommand\fR ?\fIargs...\fR?.br\fBvirtual \fIcommand\fR ?\fIargs...\fR?.BE.SH DESCRIPTION.PPThis command is considered obsolete, but is retained forbackward-compatibility with earlier versions of \fB[incr\ Tcl]\fR.It has been replaced by the \fBclass\fR command, which shouldbe used for any new development..TP\fBitcl_class \fIclassName definition\fRProvides the definition for a class named \fIclassName\fR.  If\fIclassName\fR is already defined, then this command returnsan error.  If the class definition is successfully parsed,\fIclassName\fR becomes a command in the current namespacecontext, handling thecreation of objects and providing access to class scope.The class \fIdefinition\fRis evaluated as a series of Tcl statements that defineelements within the class.  In addition to the usualcommands, the following class definition commands are recognized:.RS.TP\fBinherit \fIbaseClass\fR ?\fIbaseClass\fR...?Declares one or more base classes, causing the current class toinherit their characteristics.  Classes must have been defined bya previous \fBitcl_class\fR command, or must be available to theauto-loading facility (see "AUTO-LOADING" below).  A single classdefinition can contain no more than one \fBinherit\fR command..RS.LPWhen the same member name appears in two or more base classes,the base class that appears first in the \fBinherit\fR list takesprecedence.  For example, if classes "Foo" and "Bar" both containthe member "x", then the "\fBinherit\fR" statement:.CSinherit Foo Bar.CEallows "Foo::x" to be accessed simply as "x" but forces "Bar::x" (andall other inherited members named "x") to be referenced with theirexplicit "\fIclass\fR::\fImember\fR" name..RE.TP\fBconstructor \fIargs\fR ?\fIinit\fR? \fIbody\fRDeclares the argument list and body used for the constructor, whichis automatically invoked whenever an object is created.  Before.VSthe \fIbody\fR is executed, the optional \fIinit\fR statement isused to invoke any base class constructors that require arguments.Variables in the \fIargs\fR specification can be accessed in the\fIinit\fR code fragment, and passed to base class constructors.After evaluating the \fIinit\fR statement, any base classconstructors that have not been executed are invoked withoutarguments.  This ensures that all base classes are fullyconstructed before the constructor \fIbody\fR is executed..VEIf construction is successful, the constructor always returnsthe object name\-regardless of how the \fIbody\fR is defined\-andthe object name becomes a command in the current namespace context.If construction fails, an error message is returned..TP\fBdestructor \fIbody\fRDeclares the body used for the destructor, which is automatically invokedwhenever an object is deleted.  If the destructor is successful, the objectdata is destroyed and the object name is removed as a command from theinterpreter.  If destruction fails, an error message is returnedand the object remains..RS.LP.VSWhen an object is destroyed, all destructors in a class hierarchyare invoked in order from most- to least-specific.  This is theorder that the classes are reported by the "\fBinfo heritage\fR"command, and it is exactly the opposite of the default constructororder..VE.RE.TP\fBmethod \fIname args body\fRDeclares a method called \fIname\fR with an argument list \fIargs\fRand a \fIbody\fR of Tcl statements.  A method is just like the usualTcl "proc" except that it has transparent access to.VSobject-specific variables, as well as.VEcommon variables.  Within the class scope, a method can be invokedlike any other command\-simply by using its name.  Outside of theclass scope, the method name must be prefaced by an objectname.  Methods in a base class that are redefined in the current classor hidden by another base class can be explicitly scoped using the"\fIclass\fR::\fImethod\fR" syntax..TP\fBproc \fIname args body\fRDeclares a proc called \fIname\fR with an argument list \fIargs\fRand 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,and therefore has access only to common variables\-not.VSto object-specific variables declared with the \fBpublic\fRand \fBprotected\fR commands..VEWithin the class scope, a proc can be invokedlike any other command\-simply by using its name.  In any othernamespace context, the proc is invoked using a qualified namelike "\fIclassName\fB::\fIproc\fR".Procs in a base class that are redefined in the currentclass, or hidden by another base class, can also be accessedvia their qualified name..TP\fBpublic \fIvarName\fR ?\fIinit\fR? ?\fIconfig\fR?Declares a public variable named \fIvarName\fR.  Public variables arevisible 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"config" formal argument (see "ARGUMENT LISTS" above).  If the optional\fIinit\fR is specified, it is used as the initial value of the variablewhen a new object is created.  If the optional \fIconfig\fR commandis specified,it is invoked whenever a public variable is modified via the "config"formal argument; if the \fIconfig\fR command returns an error, thepublic variable is reset to its value before configuration, and themethod handling the configuration returns an error..TP\fBprotected \fIvarName\fR ?\fIinit\fR?Declares a protected variable named \fIvarName\fR.  Protected variablesare visible in methods within the scope of their class and any derived class,but cannotbe modified outside of the class scope.  If the optional \fIinit\fRis specified, it is used as the initial value of the variable when a newobject is created.  Initialization forces the variable to be a simplescalar value; uninitialized variables, on the other hand, can be usedas arrays.  All objects have a built-in protected variable named"this" which is initialized to the instance name for the object..TP\fBcommon \fIvarName\fR ?\fIinit\fR?Declares a common variable named \fIvarName\fR.  Common variables areshared among all objects in a class.  They are visible in methods andprocs in the scope of their class and any derived class, but cannot bemodified outside of the class scope.If the optional \fIinit\fR is specified, it is used as theinitial value of the variable.  Initialization forces the variable to bea simple scalar value; uninitialized variables, on the other hand, canbe used as arrays..RS.LPOnce a common variable has been declared, it can be configured usingordinary Tcl code within the class definition.  This facility isparticularly useful when the initialization of the variable isnon-trivial\-when the variable contains an array of values, for example:.CSitcl_class Foo {     .     .    common boolean    set boolean(true) 1    set boolean(false) 0}.CE.RE.RE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -