Index: xotcl/README.aol =================================================================== diff -u --- xotcl/README.aol (revision 0) +++ xotcl/README.aol (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,21 @@ + + Starting with Aolserver 4.* xotcl can be loaded via + package require. However, it is recommended to install + the binaries under the aolserver directory. The + recommended configuration is: + + ./configure --enable-threads --prefix=/usr/local/aolserver + + Then, you can do a + + make + make install + + We provide a small .tcl-file for providing xotcl as a module + (available in all connection threads) and easing the load of + .xotcl files (to be loaded after the xotcl extension). The + support file can be installed via: + + make install-aol + + Zoran, Gustaf Index: xotcl/doc/Announce-1.3.1 =================================================================== diff -u --- xotcl/doc/Announce-1.3.1 (revision 0) +++ xotcl/doc/Announce-1.3.1 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,13 @@ +Announcing XOTcl 1.3.1 +********************** + +This is a minor fix release relative to 1.3.0. This fixes a few +problems introduced in 1.3.0 (invocation of checking procs in +nonpositional argument) and has a better build support for building +XOTcl outside of the source tree, the tar files are now dist-cleaned. + + +Best regards, + +Gustaf Neumann +Uwe Zdun Index: xotcl/doc/Announce-1.3.3 =================================================================== diff -u --- xotcl/doc/Announce-1.3.3 (revision 0) +++ xotcl/doc/Announce-1.3.3 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,54 @@ +Announcing XOTcl 1.3.3 +********************** + +WHAT IS XOTCL? + + XOTcl is an object-oriented extension of Tcl that was derived from + OTcl. In short, XOTcl tries to provide a highly flexible, + reflective, component-based, and object-oriented environment. It + integrates language support for high level concepts which are not + found in other languages, with reasonable performance. It prevails + the Tcl programming style and the dynamic/introspective nature of + the language, rather than introducing other language's styles and + rigidness (such as C++) into Tcl. + + +Major changes relative to 1.3.1 are: + + - Qualitative Improvements + + * Improved code quality: + + fixed possible segmentation violations in free memory reads + (many thanks to Zoran Vasiljevic for his help with purify) + + fixed "self callinglevel" when uplevel was called from uplevel + + fixed nonposargs + + fixed configure in connection with enable-symbols and + for aolserver configuration + + extended regression test + + * Improved Functionality + + Producing error message when a non-existing proc/instproc + is tried to be deleted + + fixed exists method for objects with namespaces by using + a namespace resolver + + fixed return code for unknown handling in next + + reduced memory consumption for objects and classes with procs/instprocs + of about 14% + + * Improved Documentation + + + + For more details about the changes, please consult the ChangeLog and documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.4 =================================================================== diff -u --- xotcl/doc/Announce-1.3.4 (revision 0) +++ xotcl/doc/Announce-1.3.4 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,55 @@ +Announcing XOTcl 1.3.4 +********************** + +WHAT IS XOTCL? + + XOTcl is an object-oriented extension of Tcl that was derived from + OTcl. In short, XOTcl tries to provide a highly flexible, + reflective, component-based, and object-oriented environment. It + integrates language support for high level concepts which are not + found in other languages, with reasonable performance. It prevails + the Tcl programming style and the dynamic/introspective nature of + the language, rather than introducing other language's styles and + rigidness (such as C++) into Tcl. + + +Major changes relative to 1.3.3 are: + + - Qualitative Improvements + + * Improved code quality: + + fixed possible segmentation violations in free memory reads + (many thanks to Zoran Vasiljevic for his help with purify) + + fixed "self callinglevel" when uplevel was called from uplevel + + Improved portability (many thanks to Jeffrey Hobbs) + + fixed nonposargs + + fixed configure in connection with enable-symbols and + for aolserver configuration + + extended regression test + + * Improved Functionality + + Producing error message when a non-existing proc/instproc + is tried to be deleted + + fixed exists method for objects with namespaces by using + a namespace resolver + + fixed return code for unknown handling in next + + reduced memory consumption for objects and classes with procs/instprocs + of about 14% + + * Improved Documentation + + + + For more details about the changes, please consult the ChangeLog and documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.5 =================================================================== diff -u --- xotcl/doc/Announce-1.3.5 (revision 0) +++ xotcl/doc/Announce-1.3.5 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,62 @@ +Announcing XOTcl 1.3.5 +********************** + +WHAT IS XOTCL? + + XOTcl is an object-oriented extension of Tcl that was derived from + OTcl. In short, XOTcl tries to provide a highly flexible, + reflective, component-based, and object-oriented environment. It + integrates language support for high level concepts which are not + found in other languages, with reasonable performance. It prevails + the Tcl programming style and the dynamic/introspective nature of + the language, rather than introducing other language's styles and + rigidness (such as C++) into Tcl. + + +Major changes relative to 1.3.4 are: + + - Qualitative Improvements + + * Improved code quality: + + fixed possible segmentation violations in non positional + argument handling + + moved the Serializer into a namespace such that + % package req XOTcl + % package req xotcl::serializer + Serialize .... + works without namespace imports (the Serializer is + still auto-exported, but this will change in the future) + + + + * Improved Functionality + + Non-positional arguments can be used in the same argument + list as positional ones (more compliant with OpenACS). + One can write now + % Object o + % o proc foo {-x:boolean -y a b} { ...} + instead of + % ... + % o proc foo {-x:boolean -y} {a b} { ...} + All introspection commands will work like before. + The old syntax (with the additional argument) is deprecated + and will be dropped in the future. + + + Serializer: support for objects with parent namespaces, which are + not xotcl objects + + + additional instproc for ::xotcl::Class allinstances + to return all instances for the actual class + + For more details about the changes, please consult the ChangeLog and documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.6 =================================================================== diff -u --- xotcl/doc/Announce-1.3.6 (revision 0) +++ xotcl/doc/Announce-1.3.6 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,61 @@ +Announcing XOTcl 1.3.6 +********************** + +WHAT IS XOTCL? + + XOTcl is an object-oriented extension of Tcl that was derived from + OTcl. In short, XOTcl tries to provide a highly flexible, + reflective, component-based, and object-oriented environment. It + integrates language support for high level concepts which are not + found in other languages, with reasonable performance. It prevails + the Tcl programming style and the dynamic/introspective nature of + the language, rather than introducing other language's styles and + rigidness (such as C++) into Tcl. + + +Major changes relative to 1.3.5 are: + + * Improved Functionality + + new info subcommand: info precedence + + + simplified meta class definitions: every class can be + changed into a metaclass by adding an instmixin of Class (or + one of its subclasses) to it. In order to define that every + class should be a metaclass, one can use now + Object instmixin Class + instead of the rather complicated solution i posted on + the xotcl mailing list not long ago. + + * Improved code quality: + + fixed possible crashes when + - objects are called with class methods (e.g. due to instmixins) + - when instmixins are defined recursively + (e.g. Class instmixin Class) + - objects are turned into classes by changing the + class relationship + + improved namespace resolution when mixin classes are defined + in namespaces (::xotcl:: namespace is skipped, since a + helper method that calles the primitive setting command + is defined there) + + fixed passing of error code from init methods + (thanks to Fabrice Pardo for noting it) + + returning PACKAGE_VERSION after a package require + (e.g. 'package req XOTcl' returns now 1.3.6) + + some code refactoring, fixed erroneous documentation of c code + + improved documentation + + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.7 =================================================================== diff -u --- xotcl/doc/Announce-1.3.7 (revision 0) +++ xotcl/doc/Announce-1.3.7 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,65 @@ +Announcing XOTcl 1.3.7 +************************* + +I am pleased to annouce XOTcl 1.3.7. +Major changes relative to 1.3.6 are: + + * Improved Functionality + + new option "switch" for non positional arguments to be used + to toggle the default value. A switch is a non positional argument + without extra argument. + + new option "isnextcall" for self + + new command "::xotcl::configure filter on|off" to turn off filters. + needed for serializing objects/classes with active filters + + several improvements for serializer to handle e.g. application + methods on Object/Class (needed for ad_instproc in oacs) + + improving namespace resolving in for object/class references + + moving all library packages into namespaces + + preventing "new" from overwriting objects + + allow xotcl to be used in slave interpreters + + + * Improved code quality: + + fixed namespace confusion in forward to expression calling + xotcl methods + + fixed possible crash in instvar when empty variable names are used + + some code cleanup + + improved documentation + + * new method "method" for defining methods (experimental): + Instead of using e.g. + + Object o1 + Class C + + o proc m1 {} {....} + C instproc m2 {} {....} + C proc m3 {} {....} + + one can use now + + o method m1 {} {....} + C method m2 {} {....} + C method -per-object m3 {} {....} + + in general, we can support options for method definitions, which + can be used as well for mixins, filters or info (instead of the + "inst" prefix). This way the problem of finding appropriate names for + distinguishing between object or class matters can be solved, + in rather rare cases (when referring the to class object) "-per-object" + can be used. The according name changes will happen in xotcl 2.0. + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.8 =================================================================== diff -u --- xotcl/doc/Announce-1.3.8 (revision 0) +++ xotcl/doc/Announce-1.3.8 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,67 @@ +Announcing XOTcl 1.3.8 +************************* + +I am pleased to annouce XOTcl 1.3.8 +Major changes relative to 1.3.6 are: + + * Improved Functionality + + new option "switch" for non positional arguments to be used + to toggle the default value. A switch is a non positional argument + without extra argument. + + new option "isnextcall" for self + + new command "::xotcl::configure filter on|off" to turn off filters. + needed for serializing objects/classes with active filters + + several improvements for serializer to handle e.g. application + methods on Object/Class (needed for ad_instproc in oacs) + + improving namespace resolving in for object/class references + + moving all library packages into namespaces + + preventing "new" from overwriting objects + + allow xotcl to be used in slave interpreters + + + * Improved code quality: + + fixed namespace confusion in forward to expression calling + xotcl methods + + fixed possible memory leak with instmixins + + fixed possible crash in instvar when empty variable names are used + + fixed namespace related bug in __unknown resolver hook + + some code cleanup + + improved documentation + + * new method "method" for defining methods (experimental): + Instead of using e.g. + + Object o1 + Class C + + o proc m1 {} {....} + C instproc m2 {} {....} + C proc m3 {} {....} + + one can use now + + o method m1 {} {....} + C method m2 {} {....} + C method -per-object m3 {} {....} + + in general, we can support options for method definitions, which + can be used as well for mixins, filters or info (instead of the + "inst" prefix). This way the problem of finding appropriate names for + distinguishing between object or class matters can be solved, + in rather rare cases (when referring the to class object) "-per-object" + can be used. The according name changes will happen in xotcl 2.0. + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.3.9 =================================================================== diff -u --- xotcl/doc/Announce-1.3.9 (revision 0) +++ xotcl/doc/Announce-1.3.9 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,41 @@ +Announcing XOTcl 1.3.9 +************************* + +Hi everybody. I am pleased to annouce the availability of XOTcl 1.3.9. +Major changes relative to 1.3.8 are: + + * Improved Functionality + + new subcommand for self: [self args] return the full argument list + of the current call + + " info vars" does not trigger read traces on each variable anymore + + Serializer: exportMethods accepts forwards/instforwards now + as well + + new switch -nocomplain for "mixin|instmixin|filter|instfilter delete" + to avoid error messages when deleting entries not there (similar unset) + + require automatically a namespace when a childobject is added + + new command ::xotcl::__qualify: convert an relative name + into an command name (exactly as create does it, ignoring + namespaces from transparent interceptors) + + * Improved code quality: + + fixing version numbers for package require + + Upgraded TEA to 3.4 + + updated rpm build (many thanks to Ildiko Schmidt and Alexander Bergolth) + + fixed bug with error propagation when getter/setter methods are + used for parameters (many thanks to Manfred Stelzhammer for + pointing this out) + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.4.0 =================================================================== diff -u --- xotcl/doc/Announce-1.4.0 (revision 0) +++ xotcl/doc/Announce-1.4.0 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,42 @@ +Announcing XOTcl 1.4.0 +************************* + +Hi everybody. I am pleased to annouce the availability of XOTcl 1.4.0. +Major changes relative to 1.3.9 are: + + * Improved Functionality + * new option: ::xotcl::configure softrecreate on|off + if softrecreate is set, class relations (superclass, subclass, class, instances) + are not affected by a recreate; this allows files with class definitions + more easily to reload + + easier syntax for providing commands for initializing default values + + setting and querying options for ::xotcl::configure simiar to set + + * Improved code quality: + + fixed a bug in connection with nonpositional arguments and "args" + + fixed a bug with adding on the fly transitive mixin classes + + fixed a bug with filter states after next + + fixed omitted error message after calling self with unknown subcommands + + fixed a bug with variable traces on thread exit (triggered by volatile) + + fixed incorrect rpm dependencies + + cleaner compile for xotcl for gcc 4.* under linux + + don't destroy namespace imported child objects + + info children returns true children, not namespace imported objects/classes + + unsetting the global variable "cmd" from predefined.xotcl + + Upgraded TEA to 3.5 + + more regression tests addeed + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.4.1 =================================================================== diff -u --- xotcl/doc/Announce-1.4.1 (revision 0) +++ xotcl/doc/Announce-1.4.1 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,207 @@ +Announcing XOTcl 1.5.0 +************************* + +Hi everybody. I am pleased to announce the availability of XOTcl 1.5.0. +Major changes relative to 1.4.0 are: + + * Improved Functionality + + + The C-level implementation of XOTcl create now the basic + classes ::xotcl::Object and ::xotcl::Class completely without + any methods. All predefined methods are now registered + from the initialization script-code (predefined.xotcl) + via the new command + + ::xotcl::alias | \ + ?-objscope? ?-per-object? + + which is used for registering predefined Tcl commands + as methods. These aliases are like zero cost forwarders, + since they lookup the function pointer from the commands + and used these in the methods. + + This change makes it possible to register the same command + on different classes (with maybe different names), such that + for example the predefined set method of ::xotcl::Object + can be replaced with a different method and the set method + can be registered on some other classes (maybe some + application classes). This change makes it as well quite + easy to use the XOTcl framework to develop some other + object oriented frameworks. + + + slots + TODO documentation of slots + TODO remove + TODO optimize via parametercmd + TODO parametercmd with 3+ args + TODO info parameter deprecated + + A slot is a meta-object that manages property-changes of + objects. A property is either an attribute or a role of an relation. + In a nutshell, a slot has among other attributes + - a name (which it used to access it), + - a domain (object or class on which it can be used) , and + - can be multivalued or not + We distinguish between system slots (predefined slots like + class, superclass, mixin, instmixin, filter, instfilter) and + application slots (e.g. attributes of classes). + + System Slots + ======== + + System slots are predefined slots defining e.g. some relations + between classes, or between objects and classes. + + The predefined system slots are: + - superclass: every class in XOTcl has one or more superclasses. + The name of this slot is "superclass", the domain is "::xotcl::Class", + the slot is multivalued. One object might have multiple superclasses. + - class: every object has a class; therefore, the domain of the slot + is "::xotcl::Class", the property is not multivalued. + - mixin: every object in XOTcl can have one or more mixin classes. + The name of this slot is "mixin", the domain is "::xotcl::Object", the slot is + multivalued. + - instmixin: same as above, but the domain is "::xotcl::Class" + - filter, instfilter: similar to "mixin" and "instmixin" + + Every slot can be used set and query the property from its domain. + The syntax for setting values is + newValue + replace newValue + and for getting its values is + set x [ ] +TODO "mixin set" -> "mixin assign" +TODO "mixin set" -> "mixin replace" +TODO "mixin set" -> "mixin reset" +TODO "mixin delete" -> "mixin remove" + where the first form is in both cases the short form of the second one. + Every multivalued slot has as well a method "add" and "remove" + + Examples for using the system slot "mixin" + + Object o; Class M; class N + o mixin ::M ;# replacing the per-object mixins of o with M + o mixin reset ::M ;# same as before + o mixin add ::N ;# add N to the front of the mixin list + o mixin delete ::M ;# delete M from the mixin list + puts [o mixin] ;# query the current mixin list + + Every system slot (e.g. superclass) has the exact same interface. + + + Attribute Slots + ========= + + Attribute slots are used to manage the setting and querying + of instance variables. We define now a person with three + attributes,"name", "salary" and "projects". + + Class Person -slots { + Attribute name + Attribute salary -default 0 + Attribute projects -default {} -multivalued true + } + + These attributes might have a default value or they might be + multivalued. When an instance of class Person is created, the + slot names can be used for specifying values for the slots. + + Person p1 -name "Joe" + + Object p1 has three instance variables, namely "name", + "salary" and "projects". Since slot "projects" is multivalued, + we can add values the "add" subcommand. + + Project project1 -name XOTcl \ + -description "A highly flexible OO scripting language" + + p1 projects add ::project1 + p1 projects add some-other-value + + The value of the instance variable "project" of Person p1 + is now the list "some-other-value ::project1" + + + Type Checking + ========= + + Attribute slots can have types assigned which are tested + whenever the instance variable is altered. The slot "salary" + is defined as integer whereas "projects" is defined to + be a list of instances of the class Project (a list, since + "projects" is defined as multivalued). + + Class Person -slots { + Attribute name + Attribute salary -default 0 -type integer + Attribute projects -default {} -multivalued true -type ::Project + } + + Person p2 -name "Sue" -salary 1000 + + The slot types are checked via Tcl variable traces. This means + that the values are enforced now matter how the variables + are accessed. The checks are performed in the following + two commands, and they will throw an error in the second + command, since "1100x" is not an integer. + + p2 incr salary 100 + p2 append salary x + + similarly the second command below will through + an error, since some-other-value is not an instance + of ::Project. + + p2 projects add ::project1 + p2 projects add some-other-value + + When a check throws an error, the instance variables + are reset to the previous value. To restore the original + value, an associative array "__oldvalue()" is kept as + instance variable in the object. + + In general, checking of variables can be turned off globally + by "::xotcl::Slot instmixin add ::xotcl::Slot::Nocheck". + It can be turned off selectively for each slot via + a per-object-mixin; if attributes are subclassed, + it is possible to register the "Nocheck" mixin on a + subclass of Attribute. + + procsearch returns for forwarders now "forward" or "instforward", + for parametercmds now "parametercmd" or "instparametercmd" + and for other commands "cmd" and "instcmd" + +info slots +TODO slow -superclass +TODO king of the bongo + + + improved forwarding ... expr earlybinding + %argclindex + + + improved serializer + - handling of slot dependencies + - + - + + * Improved code quality: + + fixed a bug with nonpositional arguments, some + positional arguments and "args" + + fixed a bug in nonpositional arguments when called without + arguments + + improved error messages in connection with nonpositional arguments + + more regression tests added + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/Announce-1.5.0 =================================================================== diff -u --- xotcl/doc/Announce-1.5.0 (revision 0) +++ xotcl/doc/Announce-1.5.0 (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,228 @@ +Announcing XOTcl 1.5.0 +************************* + +Hi everybody. I am pleased to announce the availability of XOTcl 1.5.0. +Major changes relative to 1.4.0 are: + + * Improved Functionality + + + The C-level implementation of XOTcl create now the basic + classes ::xotcl::Object and ::xotcl::Class completely without + any methods. All predefined methods are now registered + from the initialization script-code (predefined.xotcl) + via the new command + + ::xotcl::alias | \ + ?-objscope? ?-per-object? + + which is used for registering predefined Tcl commands + as methods. These aliases are like zero cost forwarders, + since they lookup the function pointer from the commands + and used these in the methods. + + This change makes it possible to register the same command + on different classes (with maybe different names), such that + for example the predefined set method of ::xotcl::Object + can be replaced with a different method and the set method + can be registered on some other classes (maybe some + application classes). This change makes it as well quite + easy to use the XOTcl framework to develop some other + object oriented frameworks. + + + + Slots + + A slot is a meta-object that manages property-changes of + objects. A property is either an attribute or a role of an + relation. + + In a nutshell, a slot has among other attributes + - a name (which it used to access it), + - a domain (object or class on which it can be used) , and + - can be multivalued or not + + Every slot defines a uniform interface to access its + content. So has for example, every multivalued slot a + method "add" to add a value to the list of values and a + method "remove" to remove it again. + + We distinguish between system slots (predefined slots like + class, superclass, mixin, instmixin, filter, instfilter) and + application slots (e.g. attributes of classes). + + System Slots + ======== + + System slots are predefined slots defining e.g. some relations + between classes, or between objects and classes. + + The predefined system slots are: + - superclass: every class in XOTcl has one or more superclasses. + The name of this slot is "superclass", the domain is "::xotcl::Class", + the slot is multivalued. One object might have multiple superclasses. + - class: every object has a class; therefore, the domain of the slot + is "::xotcl::Class", the property is not multivalued. + - mixin: every object in XOTcl can have one or more mixin classes. + The name of this slot is "mixin", the domain is "::xotcl::Object", the slot is + multivalued. + - instmixin: same as above, but the domain is "::xotcl::Class" + - filter, instfilter: similar to "mixin" and "instmixin" + + Every slot can be used set and query the property from its domain. + The syntax for setting values is + newValue + and for getting its values is + set x [ ] + + Every multivalued slot has as well a method "add" and "remove" + + Examples for using the system slot "mixin" + + Object o; Class M; class N + o mixin ::M ;# replacing the per-object mixins of o with M + o mixin add ::N ;# add N to the front of the mixin list + o mixin delete ::M ;# delete M from the mixin list + puts [o mixin] ;# query the current mixin list + + + Attribute Slots + ========= + + Attribute slots are used to manage the setting and querying + of instance variables. We define now a person with three + attributes,"name", "salary" and "projects". + + Class Person -slots { + Attribute name + Attribute salary -default 0 + Attribute projects -default {} -multivalued true + } + + Examples for using the slots are + + Person p1 -name "Joe" + p1 projects add project1 + + Some addtional features of the slots are: + + - Support for value checking for + * primitive types (all types from "string is", like integer, + boolean, ...) + * instances of Classes (e.g. value must be an instance + of Person) + * custom value checkers + * uniform interface for single and multi-valued slots + + - Support for lazy initialization (e.g. when costly + commands (like SQL) are used to initialize instance + variables, not all variables are used for each object) + + - more experimental low level functionality, like + * initcmd (executed, whenver the variable is read the first time) + * valuecmd (executed, whenver the variable is read) + * valuechangedcmd (executed, whenver the variable is altered) + + For more details, see http://media.wu-wien.ac.at/doc/tutorial.html#slots + + + + Re-implementation of the method "parameter" based on slots. + All forms except + ... -parameter {name1 {name2 default2}} ... + (I.e. pure accessor parameters and parameters with + defaults) are deprecated, since slots are the much more + powerful and orthogonal construct. + + The old c-based parameter support based on "parameterclass" + is deprecated. It is still in the C-code (the method "parameter" + is redefined in predefined.xotcl). If someone urgently needs + it, please remove the parameter instproc from predefined + for the time being, and write an email to me, in case + you really need it). The C code for parameter will be removed + in the next release. + + + Improved introspection though the procsearch method. This + method reports now in its second argument not only + [inst]proc but as well [inst]forward, [inst]parametercmd + and [inst]cmd (the latter for methods implemented in C. + + * Improved introspection through "info" + - new subcommand "info slots" + - implemented backwards bug-compatible "info parameter", + deprecated + + + Improved serializer + - better handling of cyclical dependencies, when mixins are involved + - fix for namespace handling to make the XOTcl communication + library classes working with the aolserver (thanks for Stefan Sobernig + for pointing this out) + - Now other ::xotcl::* objects can be included in the aolserver blueprint + (e.g. non positional argument handlers) + - handling of slot dependencies + - more conveniant calling of the serializer: + Method "serialize" for Object is defined when the package xotcl::serializer + is loaded. + + + Improved forwarding commands + - New option for the argument substitution. When the argument + list of the forward command contains "%argclindex {a b c}", then + depending of the number of arguments at invocation "a", "b" + or "c" is substituted. If more arguments are used at the invocation + of the forwarder than values are contained in the list after %argclindex, + an error is generated. + - New options for forwarder: + * The option -earlybinding can be used to look + up the function pointer of the called Tcl command at + definition time of the forwarder instead of invocation time. + This option should only be used for calling C-implemented Tcl commands) + * The option -verbose prints the substituted command in the forwarder + prior to invocation. + + + New snit-like utility functions: + - ::xotcl::myvar varname: return the fully qualified variable name of the specified variable. + - ::xotcl::myproc methodname ?args?: call an xotcl method without the need + of using "[list [self] methodName ...]" + Both commands are namespace exported + + + added "subst" to the set of tcl imported methods (like e.g. incr, append, ...) + On can do now: + % Object o + ::o + % o subst {I am [self]} + I am ::o + + + added new method for ::xotcl::Object named "contains": + This method is essentially a value added back-port + of the OpenACS version. It allows to create a nested + object structure with little syntactic overhead. See tutorial + or language reference for more details. + + * Improved code quality: + + fixed a bug with nonpositional arguments, some + positional arguments and "args" + + fixed a bug in nonpositional arguments when called without + arguments + + tested with tcl 8.4.13 and 8.5a4 + + improved error messages in connection with nonpositional arguments + + fixed a bug in the xotcl trace module (many thanks to jima for reporting) + + fixed a namespace bug in ::xotcl::package require in connection with xotclide + (many thanks to Bill Paulsen and Artur Trzewik for identifying the problem and + suggesting a fix) + + improved documentation (e.g. new sections added, + some sections deleted, spelling improved, in total 8 pages longer) + + fixed documentation bugs (many thanks for Kristoffer for reporting) + + more regression tests added + + For more details about the changes, please consult the ChangeLog and + documentation. + +MORE INFO + General and more detailed information about XOTcl and its components + can be found at http://www.xotcl.org + + +Best regards, + +Gustaf Neumann +Uwe Zdun + + Index: xotcl/doc/xotcl-doc.css =================================================================== diff -u --- xotcl/doc/xotcl-doc.css (revision 0) +++ xotcl/doc/xotcl-doc.css (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,48 @@ +BODY { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-weight: normal; + background-color : white; + color: black; +} +tt { + font-family: courier, monospace; +} +A { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-weight: 100; + background-color : white; +} +A em { + font-weight: 900; +} + +pre.code { + font-size: 90%; + font-family: courier, monospace; + PADDING-RIGHT: 10px; + PADDING-LEFT: 10px; + PADDING-BOTTOM: 10px; + PADDING-TOP: 10px; + BORDER: #cccccc 1px solid; + BACKGROUND-COLOR: #eeeeee; + MARGIN-BOTTOM: 15px; +} +pre em { + font-family: cursive; + color: #888888; +} +pre tt { + font-family: helvetica; + font-weight: 900; +} +pre it { + font-style: italic; + color: green; +} +tt em { + font-family: cursive; + color: #888888; +} +table { + font-size: 80%; +} Index: xotcl/speed-1.4.1.xls =================================================================== diff -u Binary files differ Index: xotcl/tests/slottest.xotcl =================================================================== diff -u --- xotcl/tests/slottest.xotcl (revision 0) +++ xotcl/tests/slottest.xotcl (revision 2c98844f5e9a46a8ecb2c8aa8d714592a07b311d) @@ -0,0 +1,606 @@ +# $Id: slottest.xotcl,v 1.1 2006/09/14 06:42:08 neumann Exp $ +package require XOTcl +namespace import -force xotcl::* +package require xotcl::test + +proc ? {cmd expected} { + set t [Test new -cmd $cmd -count 100] + $t expected $expected + $t run +} + +proc t {cmd expected {txt ""}} { + set t [Test new -cmd $cmd -msg $txt] + $t expected $expected + $t run +} + +# what's new: +# - slots instances are manager objects for slot values +# - generalization of slots to have different kind of domains and managers +# - slots for objects and classes (slot parameter 'per-object' true|false, +# when to used on a class object) +# - works for mixins/filters/class/superclass (e.g ... superclass add ::M) +# - initcmd and valuecmd +# initcmd: is executed when the instance variable is read the first time +# valuecmd: is executed whenever the instance variable is read +# (implemented via trace; alternate approach for similar behavior +# is to define per-object procs for get/assign, see e.g. slots for +# class and superclass; slots require methods to be invoked, +# not var references; +# otoh, trace are somewhat more fragile and harder to debug) +# default, initcmd and valuecmd are to be used mutually exclusively +# - valuechangedcmd: executed after the change of an instance variable, +# can be used e.g. for validation +# +# -gustaf neumann 21.Jan. 2006 + +package require xotcl::serializer +#source /Users/neumann/src/xotcl-1.5.0/library/serialize/Serializer.xotcl +::xotcl::Object instproc serialize {} { + set s [Serializer new -volatile] + $s deepSerialize [self] +} + +#proc ? {cmd expected} { +# set r [eval $cmd] +# if {$r ne $expected} {error "$cmd returned '$r' ne '$expected'"} +#} + +# proc t {cmd {txt ""}} { +# set n 1000 +# #set ms [lindex [time [list time $cmd $n] 10] 0] +# set ms [lindex [time [list time $cmd $n] 5] 0] +# puts "[format %7.4f [expr {$ms*1.0/$n}]]ms for [format %-30s $cmd] ($txt)" +# } +####################################################### +# testing __initcmds +set ::hu 0 +proc T1 {var sub op} {c1 set $var t1} +proc T2 {var sub op} {c1 set $var t2} +Class C -array set __initcmds { + x {set x 1} + y {incr ::hu} + z {my trace add variable z read T1}} +C create c1 +? {c1 info vars x} x +? {c1 info vars y} "" +? {c1 set x} 1 +? {set ::hu} 1 + +Class D -array set __initcmds { + x {set x 2} + z {my trace add variable z read T2}} -superclass C +D create c1 +? {c1 set x} 2 +? {c1 set z} t2 +? {set ::hu} 2 + +####################################################### +# +# a small helper +Object instproc slots cmds { + if {![my isobject [self]::slot]} {Object create [self]::slot} + namespace eval [self]::slot $cmds +} + +###################### +# system slots +###################### + +Class M +Class O -mixin M +? {catch {Object o -mixin check1 M}} 1 +? {O mixin} ::M +Class M2 +O mixin add M2 +? {O mixin} {::M2 ::M} +O mixin M2 +? {O mixin} ::M2 +O mixin "" +? {O mixin} "" +O mixin set M ;# not sure, whether we should keep set here, or use assign or some better term +? {O mixin} ::M +? {O mixin ""} "" + +# with slots like class etc. we have to option to +# a) rename the original command like in the following +# b) provide a no-op value, such that we define only meta-data in the slot +# c) define a low-level tcl command like setrelation (or extend it) to handle the setter + +# "class" is not multivalued, therefore we should not add (or remove) add/delete +# from the set of subcommands... +? {::xotcl::InfoSlot class} "::xotcl::MetaSlot" +O o1 +? {o1 class} "::O" +o1 class Object +? {o1 class} "::xotcl::Object" +? {catch {o1 class add M}} 1 + + +? {O superclass} "::xotcl::Object" +Class O2 -superclass O + +#t {O2 superclass O} "superclass 1" +? {O superclass} "::xotcl::Object" + +::xotcl::Slot instproc slot {object name property} { + switch $property { + self {return [self]} + domain {return [my domain]} + } +} + +? {O superclass slot self} "::xotcl::Class::slot::superclass" +? {O superclass slot domain} "::xotcl::Class" + + +? {O2 superclass} "::O" +O2 superclass add M +? {O2 superclass} "::M ::O" +O2 superclass delete ::O +? {O2 superclass} "::M" + + +# the main difference between an Attribute and a Role is that +# it references some other objects +#Class Attribute -superclass ::xotcl::Slot +Class Role -superclass Attribute -parameter {references} + +###################### +# application classes +###################### +Class Person -slots { + Attribute name + Attribute age -default 0 +} + +Class Article -slots { + Attribute title + Attribute date +} + +Class publishes -slots { + Role written_by -references Person -multivalued true + Role has_published -references Paper -multivalued true +} + +Class Project -slots { + Attribute name + Role manager -references Person + Role member -references Person -multivalued true +} + +puts [Person serialize] +Person slot name default "gustaf" +? {Person slot name default} gustaf +Person p1 -name neophytos +? {p1 name} neophytos +? {p1 age} 0 +p1 age 123 +? {p1 age} 123 + + +Object o1 +o1 set i 0 +::xotcl::alias o1 Incr -objscope ::incr +t {o1 incr i} 1 "method incr" +t {o1 Incr i} 1002 "aliased tcl incr" +t {o1 incr i} 2003 "method incr" +t {o1 Incr i} 3004 "aliased tcl incr" + +::xotcl::alias ::xotcl::Object Set -objscope ::set +t {o1 set i 1} 1 "method set" +t {o1 set i} 1 "method set" +t {o1 Set i 1} 1 "aliased tcl set" +t {o1 Set i} 1 "aliased tcl set" +::xotcl::alias o1 Set -objscope ::set +t {o1 Set i 1} 1 "aliased object tcl set" +t {o1 Set i} 1 "aliased object tcl set" +::xotcl::Object instforward SSet -earlybinding -objscope ::set +t {o1 SSet i 1} 1 "forward earlybinding tcl set" +t {o1 SSet i} 1 "forward earlybinding tcl set" +#exit + +o1 set z 100 +#o1 forward z o1 [list %argclindex [list set set]] %proc +#o1 proc get name {my set $name} +o1 forward get -earlybinding ::xotcl::setinstvar %self %1 +? {o1 get z 101} 101 +? {o1 get z} "101" + +t {o1 get z} 101 "get value via new parametercmd get" +t {o1 get z 124} 124 "set value via new parametercmd get" + + +o1 forward zz -earlybinding ::xotcl::setinstvar %self %proc +? {o1 zz 123} 123 +? {o1 zz} 123 + +t {o1 zz} 123 "parametercmd forward earlybinding setinstvar" +t {o1 zz 124} 124 "parametercmd forward earlybinding setinstvar" + +o1 forward z2 -earlybinding -objscope ::set %proc +t {o1 z2 111} 111 "parametercmd forward earlybinding tcl set" +t {o1 z2} 111 "parametercmd forward earlybinding tcl set" + +o1 forward z3 -objscope ::set %proc +t {o1 z3 111} 111 "parametercmd forward tcl set" +t {o1 z3} 111 "parametercmd forward tcl set" + +o1 set y 11 +o1 parametercmd y +t {o1 y} 11 "parametercmd" +t {o1 y 1} 1 "parametercmd" + +#Class C -parameter {a {b 10} {c "Hello World"}} +#C copy V + +#puts [C serialize] +#puts [V serialize] + +#C destroy +#V v1 +#puts [v1 b] + +# ::xotcl::Object instproc param arglist { +# foreach arg $arglist { +# puts "arg=$arg" +# set l [llength $arg] +# set name [lindex $arg 0] +# if {![my isobject [self]::slot]} {::xotcl::Object create [self]::slot} +# if {$l == 1} { +# Attribute create [self]::slot::$name +# } elseif {$l == 2} { +# Attribute create [self]::slot::$name -default [lindex $arg 1] +# } else { +# set paramstring [string range $arg [expr {[string length $name]+1}] end] +# #puts stderr "remaining arg = '$paramstring'" +# if {[string match {[$\[]*} $paramstring]} { +# #puts stderr "match, $cl set __defaults($name) $paramstring" +# Attribute create [self]::slot::$name -default $paramstring +# continue +# } +# } +# } +# } + + +::xotcl::Slot instmixin delete ::xotcl::Slot::Optimizer + +Class C1 -parameter {a {b 10} {c "Hello World"}} +C1 c1 -a 1 +? {c1 a} 1 +? {c1 b} 10 +? {c1 c} "Hello World" + +##### is short form of + + +Class C2 -slots { + Attribute a + Attribute b -default 10 + Attribute c -default "Hello World" +} +C2 c2 -a 1 +? {c2 procsearch a} "::C2 instforward a" +? {c2 a} 1 +? {c2 b} 10 +? {c2 c} "Hello World" + + +t {c2 a} 1 "new indirect parametercmd" +t {c2 a 1} 1 "new indirect parametercmd" + +::xotcl::Slot instmixin add ::xotcl::Slot::Optimizer +Class C3 -slots { + Attribute a + Attribute b -default 10 + Attribute c -default "Hello World" +} +C3 c3 -a 1 +? {c3 procsearch a} "::C3 instparametercmd a" +? {c3 a} 1 +? {c3 b} 10 +? {c3 c} "Hello World" + +t {c3 a} 1 "new indirect parametercmd optimized" +t {c3 a 1} 1 "new indirect parametercmd optimized" + +####### nasty names +Class create D -slots { + Attribute create create -default 1 +} +D d1 + +####### gargash 2 +Class create A -parameter {{foo 1}} +# or +Class create A -slots { + Attribute foo -default 1 +} + +A create a1 -foo 234 ;# calls default foo setter + +A instproc f1 {} {puts hu} +A instforward f2 puts hu +A create a0 +#a0 f1 +a0 proc f3 {} {puts hu} +a0 forward f4 puts hu +? {a0 procsearch f1} "::A instproc f1" +? {a0 procsearch f2} "::A instforward f2" +? {a0 procsearch f3} "::a0 proc f3" +? {a0 procsearch f4} "::a0 forward f4" +? {a0 procsearch set} "::xotcl::Object instcmd set" +? {A slot foo procsearch assign} "::xotcl::Slot instcmd assign" + +# redefine setter for foo of class A +A slot foo proc assign {domain var val} { + # Do something with [self] that isn't valid pre-init + puts setter-[self proc] + $domain set $var $val +} + +a1 foo ;# calls default foo getter +a1 foo 123 ;# calls overridden foosetter +? {a1 foo} 123 + + +#puts [A serialize] + +################### +# Application Slots +# + +Class Person -slots { + Attribute name + Attribute age -default 0 + Attribute projects -default {} -multivalued true +} + +Person p1 -name "Gustaf" +? {p1 name} Gustaf +? {p1 age} 0 +? {p1 projects} {} + +Class Project -slots { + Attribute name + Attribute description +} + +Project project1 -name XOTcl -description "A highly flexible OO scripting language" + +p1 projects add ::project1 +? {p1 projects} ::project1 +#p1 projects add some-other-value +#? {p1 projects} "some-other-value ::project1" + +::xotcl::Slot instproc check { + {-keep_old_value:boolean true} + value predicate type obj var +} { + puts "+++ checking $value with $predicate ==> [expr $predicate]" + if {![expr $predicate]} { + if {[$obj exists __oldvalue($var)]} { + $obj set $var [$obj set __oldvalue($var)] + } else { + $obj unset $var + } + error "$value is not of type $type" + } + if {$keep_old_value} {$obj set __oldvalue($var) $value} +} + +::xotcl::Slot instproc checkall {values predicate type obj var} { + foreach value $values { + my check -keep_old_value false $value $predicate $type $obj $var + } + $obj set __oldvalue($var) $value +} + +Person slots { + Attribute projects -default "" -multivalued true -type ::Project + Attribute salary -type integer +} + +Person p2 -name "Gustaf" +p2 projects add ::project1 +? {catch {p2 projects add ::o1}} 1 +p2 salary 100 +? {catch {p2 salary 100.9}} 1 +? {p2 salary} 100 +p2 append salary 9 +? {p2 salary} 1009 +? {catch {p2 append salary b}} 1 +? {p2 salary} 1009 + +Person slots { + Attribute sex -type "my sex" -proc sex {value} { + switch -glob $value { + m* {my uplevel {$obj set $var m}; return 1} + f* {my uplevel {$obj set $var f}; return 1} + default {return 0} + } + } +} +Person p3 -sex male +? {p3 sex} m + +set ::hu 0 +Class C -slots { + Attribute x -initcmd {incr ::hu; set _ 101} +} +C c1 +? {c1 info vars} "" +? {c1 set x} 101 +? {c1 info vars} x +? {set ::hu 1} 1 + + +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 + } +} + +? {r0 color} pink +? {r0 r1 color} red +? {r0 r1 x1 x} 1 +? {r0 r1 x2 y} 2 +? {r0 r2 color} green +#puts [r0 serialize] + + +##### +Class create A -slots { + Attribute foo -default 1 -proc assign { domain var value} { + if {$value < 0 || $value > 99} { + error "$value is not in the range of 0 .. 99" + } + $domain set $var $value + } +} + +A create a1 +? {a1 foo 10} 10 +? {a1 foo 20} 20 +? {a1 foo} 20 +? {catch {a1 foo -1}} 1 +? {catch {a1 foo 100}} 1 +? {catch {a1 foo 99}} 0 + +exit + +#puts [Person array get __defaults] +#puts [Person serialize] +puts [Serializer all] +eval [Serializer all] + +? {p2 salary} 1009 +? {catch {p2 append salary b}} 1 +? {p2 salary} 1009 +#p2 projects add ::o1 +exit +p1 set x 0 +t {p1 set x} "get instvar value via set" +t {p1 set x 1} "set instvar value via set" + + + +Object o1 +proc f {x} {return $x} +o1 forward myf -earlybinding f +? {o1 myf abc} abc + +rename f "" +proc f {x} {return 11} +? {o1 myf abc} 11 + +Object o2 +o2 proc f {x} {expr {$x*2}} +o1 forward myf -earlybinding o2 f + +? {o1 myf 100} 200 + +o1 set x 42 +o1 forward x -earlybinding ::xotcl::setinstvar %self %proc +? [list o1 x] 42 +? [list o1 x 41] 41 +t {o1 x} "get parametercmd via forward (earlybinding)" +t {o1 x 41} "set parametercmd via forward (earlybinding)" + +#obj forward Mixin -default {getter setter} mixin %1 %self +o1 forward z -default {getter setter} %self + +o1 forward myfset -objscope set +o1 myfset y 102 +? {o1 myfset y} 102 + +t {o1 myfset y} "get instvar value via forward" +t {o1 myfset y 122} "set instvar value via forward" + +o1 forward myfdset -earlybinding -objscope set +o1 myfdset y 103 +? {o1 myfdset y} 103 + +t {o1 myfdset y} "get instvar value via forward -earlybinding" +t {o1 myfdset y 123} "set instvar value via forward -earlybinding" + +::xotcl::alias o1 myset -objscope ::set +o1 myset x 101 +? {o1 myset x} 101 + +t {o1 myset x} "get instvar value via set alias" +t {o1 myset x 123} "set instvar value via set alias" + + +t {p1 age} "slot read" +Class P -parameter {age {s -setter sets}} +P instproc sets {var value} { + my set $var $value +} +P create p2 -age 345 -s 567 + +t {p2 age} "parametercmd read" +t {::xotcl::setinstvar p2 age} "via setinstvar" +t {p2 s} "parameter read with setter" + + + + +Slot create Project::fullbudget \ + -initcmd {$obj set __x 100} \ + -valuechangedcmd { + puts "budget is now [$obj set fullbudget]" + $obj set __x [$obj set fullbudget] + } + +Slot create Project::currentbudget -valuecmd {$obj incr __x -1} + +Person p2 -name gustaf +Person p3 -name frido +Article a1 -title "My life as a saint" -date "1.1.2006" +publishes new -written_by p1 -has_published a1 +set p [Project new -name icamp -manager p2 -member add p1 -member add p3] +$p member add X end +puts [$p member] + +? [list $p fullbudget] 100 +? [list $p fullbudget] 100 +? [list $p currentbudget] 99 +? [list $p currentbudget] 98 +? [list $p fullbudget 200] 200 +? [list $p currentbudget] 199 +exit + +foreach o [Object allinstances] { + if {[$o isclass]} continue + if {[$o istype Slot]} continue + if {$o eq "::xotcl::relmgr"} continue + set string "$o\n" + foreach v [$o info vars] { + append string " $v = [$o set $v]\n" + } + puts $string +} + +puts stderr DONE-[p1 name]-[p1 age] + +p3 age 77 +exit + +puts [XoXML asXML] + +puts ==== +foreach n [XoXML selectNodes {//object[age > 1]}] {puts [$n asXML]} + +exit