Index: doc/langRef.xotcl =================================================================== diff -u -rc72f9f638677608fab1502cd696c8f2d6b2952f9 -r46f02e4868e118466d888b35d6b281b3f2ba31ac --- doc/langRef.xotcl (.../langRef.xotcl) (revision c72f9f638677608fab1502cd696c8f2d6b2952f9) +++ doc/langRef.xotcl (.../langRef.xotcl) (revision 46f02e4868e118466d888b35d6b281b3f2ba31ac) @@ -1,5 +1,5 @@ -# $Id: langRef.xotcl,v 1.18 2007/09/05 19:09:22 neumann Exp $ -package provide XOTcl-langRef 1.5.5 +# $Id: langRef.xotcl,v 1.14 2006/10/04 20:40:23 neumann Exp $ +package provide XOTcl-langRef 1.5.2 package require XOTcl @ @File { @@ -124,7 +124,7 @@ } - date { $Date: 2007/09/05 19:09:22 $ } + date { $Date: 2006/10/04 20:40:23 $ } } ## @@ -230,7 +230,7 @@ } { Description { Resets an object or class into an initial state, as after construction. - Called during recreation process by the method 'recreate' + Called during recreation process by the method recreate. } return "empty string" } @@ -239,11 +239,18 @@ ?args? "'-' method calls" } { Description { - Calls the '-' (dash) methods. I.e. evaluates arguments and calls - everything starting with '-' (and not having a digit a - second char) as a method. Every list element until the next '-' - is interpreted as a method argument. configure/tt> is called - before the constructor during initialization and recreation. + Calls the '-' (dash) methods. This method evaluates its argument list + and calls everything starting with '-' (followed by an alpha character) + as a method. Every list element until the next '-' is interpreted as an + argument of the called method. XOTcl supports argument lists with a variable + number of arguments. If an argument of a method called this way starts + with a "-", the call can be placed safely + into a list (e.g. "Class c [list -strangearg -a-] -simplearg 2") to avoid + the interpretation of "a-" as a method. +

The method configure is called automatically by + the default create and recreate methods after + the default values are set.

+

In the following example, the variable set is called via configure before init: <@pre class='code'> Object o -set x 4 @@ -470,7 +477,19 @@ return "1 or 0" } +@ Object instproc init { + args "argument list" +} { + Description { + The method <@tt>init is called automatically by the default + <@tt>create method on initialized + objects (the default variables are set, the configure + methods are already performed). This method is solely a user hook for + applications to perform class specific initialzation after object creation. + } +} + @ Object instproc incr { varName "variable name" ?increment? "value to increment" @@ -524,6 +543,11 @@ <@li><@TT>objName info filterguard name: Returns the guards for filter identified by name. + <@li><@TT>objName info forward ?-definition? name: Checks, + whether <@TT>name<@/TT> is a forwarder (accepts wild chard characters). + When <@TT>-definition is specified, it returns the definition + of the forwarder. + <@li><@TT>objName info hasNamespace: From XOTcl version 0.9 on, namespaces of objects are allocated on demand. hasNamespace returns 1, if the @@ -547,6 +571,9 @@ of the object. With <@TT>-order modifier the order of mixins (whole hierarchy) is printed. + <@li><@TT>objName info mixinguard name: Returns the guards + for the mixin identified by name. + <@li><@TT>objName info nonposargs methodName: Returns non-positional arg list of methodName @@ -912,18 +939,18 @@ } @ Class instproc alloc { obj "new obj/class name" - ?args? "arguments passed to the new class after creation" + ?args? "arguments passed during creation" } { description { - Allocate memory for a new XOTcl object or class. <@tt>create<@/tt> uses - <@tt>alloc to allocate memory. But <@tt>create<@/tt> also - calls init and evaluates '-' arguments as method calls. - In seldom cases the programmer may want to suppress the - <@tt>create<@/tt> - mechanism and just allocate memory. Then <@tt>alloc can - be used. + Allocate (create) an uninitialized object or class. Typically, alloc + is called automatically by <@tt>create<@/tt> + to allocate an uninitialized object or class. + In contrast to alloc, <@tt>create<@/tt> also + initializes and configures the object. + The method alloc can be used by a programmer who may want to + create uninitialized objects/classes. } - return "new class name" + return "fully qualified name of created instance" } @ Class instproc allinstances { @@ -941,24 +968,25 @@ description { Create user-defined classes or objects. If the class is a meta-class, a class is created, otherwise an object. + The object creation protocol implemened by create works as follows: +

- Create firstly calls <@tt>alloc in order to allocate memory for the - new object. Then default values for parameters are searched on - superclasses (an set if found). Then <@tt>args is searched for args - starting with '-' followed by an alpha character. These arguments - are called as methods. '-' followed by a numerical is interpreted - as a negative number (and not as a method). If a value of a method - called this way starts with a "a", the call can be placed safely - into a list (e.g. "Class c [-strangearg -a-] -simplearg 2"). +

In the default XOTcl definition, the <@tt>create method + is called implicitly by the <@tt>unknown method of the metaclass + Class, when a class (meta-class) is called with an unknown + method. E.g. the following two commands are equivalent - Finally the constructor <@tt>init is called on the object - with all arguments up to the first '-' arg.<@p> - - The <@tt>create method is called implicitly through the - <@tt>unknown - mechanism when a class (meta-class) is called with an unknown - method. E.g. the following two commands are equivalent - <@pre class='code'> Car herby -color red Car create herby -color red <@/pre> @@ -971,8 +999,9 @@ <@pre class='code'> Class Car -init -superclass Vehicle <@/pre> + See also: <@tt>recreate } - return "name of the created instance (result of alloc)" + return "fully qualified name of the created instance (result of alloc)" } @ Class instproc info { @@ -1023,15 +1052,23 @@ all instfilterguards are integrated (<@TT> ClassName info instfilter -guards). - <@li><@TT>objName info instfilterguard name: Returns the guards + <@li><@TT>ClassName info instfilterguard name: Returns the guards for instfilter identified by name. + <@li><@TT>ClassName info instforward ?-definition? name: Checks, + whether <@TT>name<@/TT> is a forwarder (accepts wild chard characters). + When <@TT>-definition is specified, it returns the definition + of the forwarder. + <@li><@TT>ClassName info instinvar: Returns class invariants. <@li><@TT>ClassName info instmixin: Returns the list of instmixins of this class. + <@li><@TT>ClassName info isntmixinguard name: Returns the guards + for the instmixin identified by name. + <@li><@TT>ClassName info instnonposargs methodName: returns list of non-positional args of methodName @@ -1057,6 +1094,10 @@ Returns a list of all super-classes of the class, if superclassname was not specified, otherwise it returns 1 if superclassname is a superclass and 0 if not. + + <@li><@TT>ClassName info slots: + Returns the slot objects defined for this class. + <@/ul> } return "Value of introspected option as a string." @@ -1216,7 +1257,7 @@ @ Class instproc instproc { name "instance method name" - ?non-pos-args?" "optional non-positional arguments" + "?non-pos-args?" "optional non-positional arguments" args "instance method arguments" body "instance method body" "?preAssertion?" "optional assertions that must hold before the proc executes" @@ -1248,7 +1289,7 @@ If <@tt>-childof obj is specified, the new object is created as a child of the specified object. } - return "new object name" + return "fully qualified name of the created instance" } @ Class instproc parameter { @@ -1307,13 +1348,29 @@ ?args? "arbitrary arguments" } { description { - Hook called upon recreation of an object. Performs standard object - initialization, per default. May be overloaded/-written. It calls - another method cleanup which handles actual cleanup of the object - during next. That means, if you overload recreate, in the pre-part - the object still contains its old state, after next it is cleaned up. + Hook called upon recreation of an object in cases where the user wants to distinguish + between creation and recreation of objects. A recreation occurs, when an Object is created + with a name that exists already. + A typical use-case is the redefinition + of classes in and IDE, where the relations between classes/classes and object/classes + should be preserved (this is different to a destroy of the object). + +

The method recreate does not need to call alloc + but calls instead cleanup + to reset to the object (or class) to its initial state (e.g. remove variables, child objects, + for classes remove instaces, etc.). Then it performs the standard initialization + for the object or class. + +

If recreate is overloaded and the default recreate method is called via next, + the pre-part + (before next) contains its old state of the object, + while during the part after next the + object is cleaned up. +

To ease recreation of classes, see ::xotcl::configure softrecreate. + + See also: <@tt>create } - return "obj name" + return "fully qualified name of instance" } @ Class instproc superclass {