# $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 { description { XOTcl language reference. Describes predefined objects and classes. } "predefined primitives" { XOTcl contains the following predefined primitives (Tcl commands):
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@pre>
The method configure can be called with the
dash-notation at arbitrary times:
<@pre class='code'> o configure -set x 4@pre>
}
return "number of the skipped first arguments"
}
@ Object instproc contains {
"?-withnew?" "Option to overload new to create new objects within
the specified object. Per default, this option is turned on."
"?-object?" "object, in which the new objects should be created.
The default is the object, for which contains>/tt> was called."
"?-class?" "In combination with option -object: If the specified
object does not exist, create it from the specified class. The default
is ::xotcl::Object"
cmd "Tcl command to create multiple objects"
} {
Description {
This method can be used to create nested object structures
with little syntactic overhead. The method changes the namespace
to the specified object and creates objects there.
Optionally, a different object scope can be specified and
creating new objects in the specified scope can be turned off.
The following command creates a three rectangles, containing some
points.
Class Point -parameter {{x 100} {y 300}}
Class Rectangle -parameter {color}
Rectangle r0 -color pink -contains {
Rectangle r1 -color red -contains {
Point x1 -x 1 -y 2
Point x2 -x 1 -y 2
}
Rectangle r2 -color green -contains {
Point x1
Point x2
}
}
The resulting object structure looks like in the folloing
example (simplified).
::r0
::r0::r1
::r0::r1::x1
::r0::r1::x2
::r0::r2
::r0::r2::x1
::r0::r2::x2
}
return "number of the skipped first arguments"
}
@ Object instproc copy {
newName "destination of copy operation"
} {
Description {
Perform a deep copy of the object/class (with all information, like
class, parameter, filter, ...)
to "newName".
}
return "empty string"
}
@ Object instproc destroy {
?args? "Arbitrary arguments passed to the destructor"
} {
Description {
Standard destructor.
Can be overloaded for customized destruction process. Actual destruction
is done by instdestroy. "destroy" in principal does:
<@pre class='code'>
Object instproc destroy args {
[my info class] instdestroy [self]
}@pre>
}
return "empty string"
}
@ Object instproc eval {
args "cmds to eval"
} {
Description {
Eval args in the scope of the object. That is local variables
are directly accessible as Tcl vars.
}
return "result of cmds evaled"
}
@ Object instproc extractConfigureArg {
al "Argument List Name"
name "Name of the configure argument to be extracted (should start with '-')"
?cutTheArg? "if cutTheArg not 0, it cut from upvar argsList, default is 0"
} {
Description {
Check an argument list separated with '-' args, as for instance
configure
arguments, and extract the argument's values. Optionally, cut the
whole argument.
}
return "value list of the argument"
}
@ Object instproc exists {
var "variable name"
} {
Description {
Check for existence of the named instance variable on the object.
}
return "1 if variable exists, 0 if not"
}
@ Object instproc filter {
?args? "filter specification"
} {
Description {
If <@tt>$args@tt> is one argument, it specifies a list of filters to
be set. Every filter must be an XOTcl proc/instproc within
the object scope.
If <@tt>$args@tt> it has more argument, the first one specifies the
action. Possible values are <@tt>assign@tt>, <@tt>get@tt>,
<@tt>add@tt> or <@tt>delete@tt>, it modifies the current
settings as indicated. For more details, check the
tutorial.
}
return "if <@tt>$args@tt> return empty current filters, otherwise empty"
}
@ Object instproc filterguard {
filterName "filter name of a registered filter"
guard "set of conditions to execute the filter"
} {
description {
Add conditions to guard a filter registration point. The filter
is only executed, if the guards are true. Otherwise we ignore the
filter. If no guards are given, we always execute the filter.
}
return "an empty string"
}
@ Object instproc filtersearch {
methodName "filter method name"
} {
description {
Search a full qualified method name that
is currently registered as a filter. Return a list of the
proc qualifier format:
'objName|className proc|instproc methodName'.
}
return "full qualified name, if filter is found, otherwise an empty string"
}
@ Object instproc forward {
methodName "name of forwarder method"
?options? "-objscope, -methodprefix string, -default names, -earlybinding, -verbose"
?callee? "named of the called command or object"
?args? "arguments"
} {
Description {
Register an object specific method (similar to a proc) for forwarding calls to
a callee (target Tcl command, other object).
When the forwarder method is called, the actual arguments
of the invocation are appended to the specified arguments. In callee an
arguments certain substitutions can take place:
Additionally each argument can be prefixed by the positional prefix %@POS
(note the delimiting space at the end) that can be used to specify an
explicit position. POS can be a positive or negative integer or the word
end. The positional arguments are evaluated from left to
right and should be used in ascending order. valid Options are:
See
tutorial
for detailed examples.
}
return "empty"
}
@ Object instproc hasclass {
?className? "name of a class to be tested"
} {
Description {
Test whether the argument is either
a mixin or instmixin of the object or
if it is on the class hierarchy of the object.
This method combines the functionalities of
istype and ismixin.
}
return "1 or 0"
}
@ Object instproc init {
args "argument list"
} {
Description {
The method <@tt>init is called automatically by the default
<@tt>create@tt> 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"
} {
Description {
Increments the value stored in the variable whose name is varName.
The new value is stored as a decimal string in variable varName and also
returned as result. Wrapper to the same named Tcl command
(see documentation of Tcl command with the same name for details).
}
return "new value of varName"
}
@ Object instproc info {
args "info options"
} {
Description {
Introspection of objects. The following options can be specified:
<@l>
<@li><@TT>objName info args method@TT>:
Returns the arguments of the specified proc (object specific method).
<@li><@TT>objName info body method@TT>:
Returns the body of the specified proc (object specific method).
<@li><@TT>objName info class ?classname?@TT>:
Returns the name of the class of the current object, if className was
not specified, otherwise it returns 1 if className matches the
object's class and 0 if not.
<@li><@TT>objName info children ?pattern?@TT>: Returns the
list of aggregated objects with fully qualified names if
<@TT>pattern@TT> was not specified, otherwise it returns all
children where the object name matches the pattern.
<@li><@TT>objName info commands ?pattern@TT>: Returns all
commands defined for the object if <@TT>pattern@TT> was not
specified, otherwise it returns all commands that match the
pattern.
<@li><@TT>objName info default method arg var@TT>: Returns 1
if the argument <@TT>arg@TT> of the proc (object specific
method) <@TT>method@TT> has a default value, otherwise 0. If
it exists the default value is stored in <@TT>var@TT>.
<@li><@TT>objName info filter@TT>: Returns a list of filters.
With -guard modifier all filterguards are integrated
(<@TT> objName info filter -guards@TT>). With <@TT>-order@TT>
modifier the order of filters (whole hierarchy) is printed.
<@li><@TT>objName info filterguard name@TT>: Returns the guards
for filter identified by name.
<@li><@TT>objName info forward ?-definition? name@TT>: Checks,
whether <@TT>name<@/TT> is a forwarder (accepts wild chard characters).
When <@TT>-definition@/TT> is specified, it returns the definition
of the forwarder.
<@li><@TT>objName info hasNamespace@TT>: From XOTcl version 0.9 on,
namespaces
of objects are allocated on demand. hasNamespace returns 1, if the
object currently has a namespace, otherwise 0. The method
<@TT>requireNamespace@TT> can
be used to ensure that the object has a namespace.
<@li><@TT>objName info info@TT>: Returns a list of all available info
options on the object.
<@li><@TT>objName info invar@TT>: Returns object invariants.
<@li><@TT>objName info methods@TT>: Returns the list of all methods
currently reachable for objName. Includes procs, instprocs, cmds,
instcommands on object, class hierarchy and mixins.
Modifier <@TT>-noprocs@TT> only returns instcommands,
<@TT>-nocmds@TT> only returns procs.
Modifier <@TT>-nomixins@TT> excludes search on mixins.
<@li><@TT>objName info mixin@TT>: Returns the list of mixins
of the object. With <@TT>-order@TT> modifier the order of mixins
(whole hierarchy) is printed.
<@li><@TT>objName info mixinguard name@TT>: Returns the guards
for the mixin identified by name.
<@li><@TT>objName info nonposargs methodName@TT>: Returns
non-positional arg list of methodName
<@li><@TT>objName info parent@TT>:
Returns parent object name (or "::" for no parent),
in fully qualified form.
<@li><@TT>objName info post methodName@TT>:
Returns post assertions of methodName.
<@li><@TT>objName info pre methodName@TT>:
Returns pre assertions of methodName.
<@li><@TT>objName info procs ?pattern?@TT>: Returns all procs
defined for the object if <@TT>pattern@TT> was not specified,
otherwise it returns all procs that match the pattern.
<@li><@TT>objName info precedence ?pattern?@TT>: Returns all
classes in the precedence order from which the specified
object inherits methods. The returned list of classes contains
the mixin and instmixin classes as well as the classes of the
superclass chain in linearized order (i.e., duplicate classes
are removed). If the pattern is specified, only matching classes
are returned.
<@li><@TT>objName info vars ?pattern?@TT>: Returns all
variables defined for the object if <@TT>pattern@TT> was not
specified, otherwise it returns all variables that match the
pattern. <@/ul>
}
return "Value of introspected option as a string."
}
@ Object instproc instvar {
v1 "name of instance variable"
"?v2...vn?" "optional other names for instance variables"
} {
Description {
Binds an variable of the object to the current method's scope.
Example:
<@pre class='code'>
kitchen proc enter {name} {
my instvar persons
set persons($name) [clock seconds]
}@pre>
Now persons can be accessed as a local variable of the method.<@br>
A special syntax is: <@tt> {varName aliasName} @tt>.
This gives the variable with the name
<@TT>varName@TT> the alias <@TT>aliasName@TT>.
This way the variables can be linked to the methods scope,
even if a variable with that name already exists in the scope.
}
return "empty string"
}
@ Object instproc invar {
invariantList "Body of invariants for the object"
} {
Description {
Specify invariants for the objects. All assertions are a list
of ordinary Tcl conditions.
}
return "empty string"
}
@ Object instproc isclass {
?className? "name of a class to be tested"
} {
Description {
Test whether the argument (or the Object, if no argument is specified)
is an existing class or not.
}
return "1 or 0"
}
@ Object instproc ismetaclass {
?metaClassName? "name of a metaclass to be tested"
} {
Description {
Test whether the argument (or the Object, if no argument is specified)
is an existing metaclass or not.
}
return "1 or 0"
}
@ Object instproc ismixin {
?className? "name of a class to be tested"
} {
Description {
Test whether the argument is a mixin or instmixin of the object.
}
return "1 or 0"
}
@ Object instproc isobject {
objName "string that should be tested, whether it is a name of an object or not"
} {
Description {
Test whether the argument is an existing object or not. Every XOTcl object
has the capability to check the object system.
}
return "1 or 0"
}
@ Object instproc istype {
className "type name"
} {
Description {
Test whether the argument is a type of the object. I.e., 1 is returned
if className is either the class of the object or one of its
superclasses.
}
return "1 or 0"
}
@ Object instproc lappend {
varName "name of variable"
args "elements to append"
} {
Description {
Append all the specified arguments to the list specified
by varName as separated elements (typically separated by blanks).
If varName doesn't exist, it creates a list with the specified
values
(see documentation of Tcl command with the same name for details).
}
return "empty string"
}
@ Object instproc mixin {
?args? "mixin specification"
} {
Description {
If <@tt>$args@tt> is one argument, it specifies a list of mixins to
be set. Every mixin must be a defined class.
If <@tt>$args@tt> has more argument, the first one specifies the
action. Possible values are <@tt>assign@tt>, <@tt>get@tt>,
<@tt>add@tt> or <@tt>delete@tt>, it modifies the current
settings as indicated. For more details, check the
tutorial.
}
return "if <@tt>$args@tt> empty return current mixins, otherwise empty"
}
@ Object instproc move {
newName "destination of move operation"
} {
Description {
Perform a deep move of the object/class (with all information, like
class, parameter, filter, ...)
to "newName".
Note that move is currently implemented as a copy plus
subsequent destroy operation.
}
return "empty string"
}
@ Object instproc parametercmd {
name "variable to be provided with getter/setter method"
} {
description {
Add a getter/setter for an instance variable with the
specified name as a command for the obj.
Example:
<@pre class='code'>
Object o
o parametercmd x
o x 100
puts [o x]@pre>
}
return "empty string"
}
@ Object instproc noinit {
} {
description {
flag that constructor (method <@tt>init) should
not be called.
Example:
<@pre class='code'>
Class C
C instproc init {} {puts hu}
C c1 -noinit@pre>
The object <@tt>c1@tt> will be created without calling
the constructor. This can be used to draw a snapshot of
an existing object (using the serializer) and to recreate
it in some other context in its last state.
}
return "empty string"
}
@ Object instproc proc {
name "method name"
?non-pos-args? "optional non-positional arguments"
args "method arguments"
body "method body"
"?preAssertion?" "optional assertions that must hold before the proc executes"
"?postAssertion?" "optional assertions that must hold after the proc executes"
} {
Description {
Specify a method in the same style as Tcl specifies procs.
<@br>
Optionally assertions may be specified by two additional arguments.
Therefore, to specify only post-assertions an empty pre-assertion
list must be given. All assertions are a list
of ordinary Tcl conditions.
<@br>
When instproc is called with an empty argument list and an empty
body, the specified instproc is deleted.
}
return "empty string"
}
@ Object instproc procsearch {
procName "simple proc name"
} {
Description {
Search which method should be invoked for an object and return the fully
qualified name of the method as a list in
proc qualifier format:
'objName|className proc|instproc|forward|instforward|parametercmd|instparametercmd|cmd|instcmd methodName'.
The proc qualifier format reports the command used to create the method. The
only exception is instcmd and cmd, which refer to commands implemented in C.
E.g.,
<@pre class='code'> o procsearch set @pre>
returns <@pre>::xotcl::Object instcmd set@pre>.
}
return "fully qualified name of the searched method or empty string if not found"
}
@ Object instproc requireNamespace {
} {
Description {
The method <@TT>requireNamespace@TT> can
be used to ensure that the object has a namespace.
Namespaces are created automatically by XOTcl, when e.g. an object has
child objects (aggregated objects) or procs. The namespace
will be used to keep instance variables, procs and child objects.
To check, whether an object currently has a namespace,
<@TT>info hasNamespace@TT> can be used.
Hint: In versions prior to XOTcl 0.9 all XOTcl objects
had their own namespaces; it was made on demand to save memory when
e.g. huge numbers of objects are created.
<@TT>requireNamespace@TT> is often needed when e.g. using Tk widgets
when variables are to be referenced via the namespace
(with <@TT>... -variable [self]::varName ...@TT>).
}
return "empty string"
}
@ Object instproc set {
varName "name of the instance variable"
?value? "optional new value"
} {
Description {
Set an instance variable in the same style as Tcl sets a variable.
With one argument, we retrieve the current value,
with two arguments, we set the instance variable to the new value.
}
return "Value of the instance variable"
}
@ Object instproc subst {
options "?-nobackslashes? ?-nocommands? ?-novariables?"
string "string to be substituted"
} {
Description {
Perform backslash, command, and variable substitutions
in the scope of the given object
(see documentation of Tcl command with the same name for details).
}
return "substituted string"
}
@ Object instproc trace {
varName "name of variable"
} {
Description {
Trace an object variable
(see documentation of Tcl command with the same name for details).
}
return "empty string"
}
@ Object instproc unset {
"?-nocomplain?" "possible error messages are suppressed"
v1 "Variable to unset"
"?v2...vn?" "Optional more vars to unset"
} {
Description {
The unset operation deletes one or optionally a set of variables from an object.
}
return "empty string"
}
@ Object instproc uplevel {
?level? "Level"
command ?args? "command and arguments to be called"
} {
Description {
When this method is used without the optional level, it is a short form
of the Tcl command
<@pre class='code'> uplevel [self callinglevel] command ?args?<@/pre>
When it is called with the level, it is compatible with the original Tcl command.
}
return "result of the command"
}
@ Object instproc upvar {
?level? "Level"
otherVar localVar "referenced variable and variable in the local scope"
?otherVar localVar? "optional pairs of referenced and local variable names"
} {
Description {
When this method is used without the optional level, it is a short form
of the Tcl command
<@pre class='code'> upvar [self callinglevel] otherVar localVar ?...?<@/pre>.
When it is called with the level, it is compatible with the original Tcl command.
}
return "result of the command"
}
@ Object instproc vwait {
varName "name of variable"
} {
Description {
Enter event loop until the specified variable is set
(see documentation of Tcl command with the same name for details).
}
return "empty string"
}
# procs of Object
@ Object proc getExitHandler {} {
Description "Retrieve the current exit handler procedure body as a string."
return "exit handler proc body"
}
@ Object proc setExitHandler {body "procedure body"} {
Description {
Set body for the exit handler procedure. The exit handler
is executed when XOTcl is existed or aborted. Can be used to call
cleanups that are not associated with objects (otherwise use
destructor).
On exit the object destructors are called after the
user-defined exit-handler.
}
return "exit handler proc body"
}
# class
@ Class Class -superclass Object {
description {
This meta-class holds the pre-defined methods available for all XOTcl
classes.
}
}
@ Class instproc alloc {
obj "new obj/class name"
?args? "arguments passed during creation"
} {
description {
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 "fully qualified name of created instance"
}
@ Class instproc allinstances {
} {
description {
Compute all immediate and indirect instances of a class
}
return "fully qualified list of instances"
}
@ Class instproc create {
objName "name of a new class or object"
?args? "arguments passed to the constructor"
} {
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:
In the default XOTcl definition, the <@tt>create@tt> method is called implicitly by the <@tt>unknown@tt> method of the metaclass Class, 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> When a users may want to call the constructor <@tt>init@tt> before other '-' methods, one can specify '-init' explicitly in the left to right order of the '-' method. Init is called always only once. e.g.: <@pre class='code'> Class Car -init -superclass Vehicle <@/pre> See also: <@tt>recreate@tt> } return "fully qualified name of the created instance (result of alloc)" } @ Class instproc info { args "info options" } { Description { Introspection of classes. All options available for objects (see <@a href="#Object-info">info object@a>) is also available for classes. The following options can be specified: <@ul> <@li><@TT>ClassName info classchildren ?pattern?@TT>: Returns the list of nested classes with fully qualified names if <@TT>pattern@TT> was not specified, otherwise it returns all class children where the class name matches the pattern. <@li><@TT>ClassName info classparent@TT>: Returns the class ClassName is nesting to. <@li><@TT>ClassName info heritage ?pattern?@TT>: Returns a list of all classes in the precedence order of the class hierarchy. If pattern is specified, only matching values are returned. <@li><@TT>ClassName info instances ?pattern?@TT>: Returns a list of the instances of the class. If pattern is specified, only matching values are returned. <@li><@TT>ClassName info instargs method@TT>: Returns the arguments of the specified instproc (instance method). <@li><@TT>ClassName info instbody method@TT>: Returns the body of the specified instproc (instance method). <@li><@TT>ClassName info instcommands ?pattern?@TT>: Returns all commands defined for the class. If pattern is specified it returns all commands that match the pattern. <@li><@TT>ClassName info instdefault method arg var@TT>: Returns 1 if the argument <@TT>arg@TT> of the instproc (instance method) <@TT>method@TT> has a default value, otherwise 0. If it exists the default value is stored in <@TT>var@TT>. <@li><@TT>ClassName info instfilter@TT>: Returns the list of registered filters. With -guard modifier all instfilterguards are integrated (<@TT> ClassName info instfilter -guards@TT>). <@li><@TT>ClassName info instfilterguard name@TT>: Returns the guards for instfilter identified by name. <@li><@TT>ClassName info instforward ?-definition? name@TT>: Checks, whether <@TT>name<@/TT> is a forwarder (accepts wild chard characters). When <@TT>-definition@/TT> is specified, it returns the definition of the forwarder. <@li><@TT>ClassName info instinvar@TT>: Returns class invariants. <@li><@TT>ClassName info instmixin@TT>: Returns the list of instmixins of this class. <@li><@TT>ClassName info isntmixinguard name@TT>: Returns the guards for the instmixin identified by name. <@li><@TT>ClassName info instnonposargs methodName@TT>: returns list of non-positional args of methodName <@li><@TT>ClassName info instpost methodName@TT>: Returns post assertions of methodName. <@li><@TT>ClassName info instpre methodName@TT>: Returns pre assertions of methodName. <@li><@TT>ClassName info instprocs ?pattern?@TT>: Returns all instprocs defined for the class. If pattern is specified it returns all instprocs that match the pattern. <@li><@TT>ClassName info parameter@TT>: Returns parameter list. <@li><@TT>ClassName info subclass ?subclassname?@TT>: Returns a list of all subclasses of the class, if subclassname was not specified, otherwise it returns 1 if subclassname is a subclass and 0 if not. <@li><@TT> ClassName info superclass ?superclassname?@TT>: 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@TT>: Returns the slot objects defined for this class. <@/ul> } return "Value of introspected option as a string." } @ Class instproc instdestroy { obj "obj/class name" ?args? "arguments passed to the destructor" } { Description { Standard destructor. Destroys XOTcl object physically from the memory. Can be overloaded for customized destruction process. <@p> In XOTcl objects are not directly destroyed, when a destroy is encountered in a method. Beforehand, the interpreter looks up whether the object is still referenced on the method callstack or not. If not, the object is directly destroyed. Otherwise every occurrence of the object on the callstack is marked as destroyed. During popping of the callstack, for each object marked as destroyed, the reference count is decremented by one. When no more references to the object are on the callstack the object is physically destroyed. This way we can assure that objects are not accessed with [self] in running methods after they are physically destroyed. } return "empty string" } @ Class instproc instfilter { ?args? "instfilter specification" } { Description { If <@tt>$args@tt> is one argument, it specifies a list of instfilters to be set. Every filter must be an XOTcl proc/instproc within the object scope. If <@tt>$args@tt> it has more argument, the first one specifies the action. Possible values are <@tt>assign@tt>, <@tt>get@tt>, <@tt>add@tt> or <@tt>delete@tt>, it modifies the current settings as indicated. For more details, check the tutorial. } return "if <@tt>$args@tt> return empty current instfilters, otherwise empty" } @ Class instproc instfilterguard { filterName "filter name of a registered filter" guard "set of conditions to execute the filter" } { description { Add conditions to guard a filter registration point. The filter is only executed, if the guards are true. Otherwise we ignore the filter. If no guards are given, we always execute the filter. } return "empty string" } @ Class instproc instforward { methodName "name of forwarder method" ?options? "-objscope, -methodprefix string, -default names, -earlybinding, -verbose" ?callee? "named of the called command or object" ?args? "arguments" } { Description { Register a method for the instances of a class (similar to an instproc) for forwarding calls to a callee (target Tcl command, other object). When the forwarder method is called, the actual arguments of the invocation are appended to the specified arguments. In callee an arguments certain substitutions can take place:
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@tt> } return "fully qualified name of instance" } @ Class instproc superclass { classList "?list of classes?" } { description { Specify super-classes for a class. "superclass" changes the list of superclasses dynamically to <@tt>classList@tt>. The method returns the current value of superclass, when it is called without arguments. } return "if <@tt>classList@tt> is not specified return superclass(es), otherwise empty" } @ Class instproc unknown { ?args? "arbitrary arguments" } { description { Standard unknown mechanism. This mechanism is always triggered when XOTcl does not know a method called on an object. Supposed that there is no method with the called name, XOTcl looks up the method "unknown" (which is found on the Class Object) and executes it. The standard unknown-mechanism of XOTcl calls create with all arguments stepping one step to the right; in the general case: <@pre class='code'> ClassName create ClassName ?args?<@/pre> Unknown can be overloaded in user-defined subclasses of class. } return "Standard unknown mechanism returns result of create" } @ Object instproc volatile { "" "" } { description { This method is used to specify that the object should be deleted automatically, when the current Tcl-proc/object-proc/instproc is left. Example: <@pre class='code'> set x [Object new -volatile]@pre> } return "empty string" } @ Class proc __unknown { "name" "name of class to be created" } { description { This method is called, whenever XOTcl references a class, which is not defined yet. In the following example: <@tt>Class C -superclass D@tt> D is not defined. Therefore <@tt>Class __unknown D@tt> is called. This callback can be used to perform auto-loading of classes. After this call, XOTcl tries again to resolve D. If it succeeds, XOTcl will continue; otherwise, an error is generated. <@p> This method is called on mixin/instmixin definition calls, istype, ismixin, class, superclass and parameterclass } return "empty string" } @ Class ::xotcl::Slot -superclass Object { description { A slot is a meta-object that manages property-changes of objects. A property is either an attribute or a role of an relation (e.g. in system slots). The predefined system slots are class, superclass, mixin, instmixin, filter, instfilter. These slots appear as methods of Object or Class.
The slots provide a common query and setting interface. Every multivalued slot provides e.g. a method add to add a value to the list of values, and a method delete which removes it. See for example the documentation of the slot mixin.
Parameters:
-name | Name of the slot to access from an object the slot |
-domain | domain (object or class) of a slot on which it can be used |
-multivalued | boolean value for specifying single or multiple values (lists) |
-defaultmethods | list of two elements for specifying which methods are called per default, when no slot method is explicitly specified |
-manager | the manager object of the slot (per default [self]) |
-per-object | specify whether a slot should be used per class or per object; note that there is a restricted usage if applied per class, since defaults etc, work per initialization |
For more details, consult the tutorial.
} } @ Class Attribute -superclass ::xotcl::Slot { description { Attribute slots are used to manage the setting and querying of instance variables. Parameters:
-default | specify a default value |
-type | specify the type of a slot |
-initcmd | specify a Tcl command to be executed when the value of the associated variable is read the first time; allows lazy initialization |
-valuecmd | specify a Tcl command to be executed whenever the variable is read |
-valuechangedcmd | specify a Tcl command to be executed whenever the variable is changed |
Example of a class definition with three attribute slots:
<@tt>Class Person -slots { Attribute name Attribute salary -default 0 Attribute projects -default {} -multivalued true } Person p1 -name "John Doe" @pre>The slot parameters default, initcmd and valuecmd have to be used mutually exclusively. For more details, consult the tutorial.
} } #Class::Parameter instproc values {param args} #proc xotcl_mkindex #proc xotcl_load