Index: doc/migration1-2.html =================================================================== diff -u -rc619db7db573de1047ec1810dc0a8dc4d86ce98d -reef622da1b387cfd1dd68babeb0bfecfbae5caa3 --- doc/migration1-2.html (.../migration1-2.html) (revision c619db7db573de1047ec1810dc0a8dc4d86ce98d) +++ doc/migration1-2.html (.../migration1-2.html) (revision eef622da1b387cfd1dd68babeb0bfecfbae5caa3) @@ -9,13 +9,16 @@ color: black; } table i { - font-size: 80%; + font-size: 80%; } table td code i { - font-style: italic; - color: green; + font-style: italic; + color: green; } - +pre i { + font-style: italic; + color: green; +} th {color: #888888;} td hr { color: #FFFFFF; @@ -39,6 +42,7 @@ } table td { width: 400; + padding: 10px; border:1px solid #AAAAAA; } @@ -52,15 +56,48 @@

Supporting XOTcl 1 in XOTcl 2

-

-... multiple object systems .... -

-::xotcl::use xotcl1 -

-::xotcl::use xotcl2 -

-describe, what ::xotcl::use does +

In general, the XOTcl 2 environment supports multiple object +systems concurrently. Effectively, every object system has different +base classes for creating both, objects and classes. Therefore, the +object systems can have different different interfaces and names of +builtin methods. Currently, XOTcl 2 supports primarily XOTcl 1 and +XOTcl 2 (XOTcl 1 provides about twice as many predefined builtin +methods).

+

The support for multiple object systems can be used to load XOTcl +1 and XOTcl 2 scripts into the same interpreter. This makes migration +from XOTcl 1 to XOTcl 2 easier. The XOTcl environment provides the +predefined command ::xotcl::use to make switching between these +objects systems convenient. The following example script shows a single +script defining classes of XOTcl 1 and 2:

+ +

+   package require XOTcl
+
+   namespace eval mypackage {
+
+      # Some definitions for XOTcl 1
+      ::xotcl::use xotcl1
+
+      Class C1
+      C1 instproc foo {} {puts "hello world"}
+
+      # Some definitions for XOTcl 2
+      ::xotcl::use xotcl2
+
+      Class create C2 {
+         .method foo {} {puts "hello world"}
+      }
+   }
+
+ +

"Switching" effectively means the load some libraries if needed +and to import either the XOTcl 1 or XOTcl 2 base classes as +Object and Class into the current namespace. +If the import is not wanted, just use package require to +load the necessary pieces. +

+

XOTcl 1 Idioms in XOTcl 2

Defining Objects and Classes

@@ -118,7 +155,16 @@ +

Resolvers

+XOTcl 2 defines Tcl resolvers for method and variable names to refer +to object specific behavior. Withing method bodies these resolver +treat names staring with a dot "." specially. If one wants to refer to +a name starting with a "." (e.g. the name of a Tcl function starts +with a dot), the dot has to be duplicated, or one has to use the +usual namespace prefix "::" to refer to a namespaced entity. Note that +the XOTcl 2 resolver is used in the XOTcl 1 environment as well. +

Invoking Methods

@@ -151,6 +197,30 @@
XOTcl 1XOTcl 2
+ + + + @@ -393,6 +463,35 @@ object as shown in examples above.

+

List filter or mixins

+
XOTcl 1XOTcl 2
Class C
+ C instproc foo args {
+   # method scoped variable a
+   set a 1
+   # instance variable b
+   my instvar b
+   set b 2
+   # global variable/namespaced variable c
+   set ::c 3
+ }
+
Class create C {
+   .method foo args {...}
+     # method scoped variable a
+     set a 1
+     # instance variable b
+     set .b 2
+     # global variable/namespaced variable c
+     set ::c 3
+   }
+ }
+
my set varname value set .varname value
+ + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl 1XOTcl 2
obj info filter ?-order? ?-guards? ?pattern?obj info filter ?-order? ?-guards? ?pattern?
cls info filter ?-order? ?-guards? ?pattern?cls object info filter ?-order? ?-guards? ?pattern?
cls info instfilter ?-order? ?-guards? ?pattern?cls info filter ?-order? ?-guards? ?pattern?
obj info mixin ?-order? ?-guards? ?pattern?obj info mixin ?-order? ?-guards? ?pattern?
cls info mixin ?-order? ?-guards? ?pattern?cls object info mixin ?-order? ?-guards? ?pattern?
cls info instmixin ?-order? ?-guards? ?pattern?cls info mixin ?-order? ?-guards? ?pattern?
+

List definition of methods defined by aliases, setters or forwarders

@@ -402,8 +501,8 @@ - - cls ?object? info method definition methodName +
XOTcl 1XOTcl 2
n.a.cls info method definition methodName

List fully qualified name of method

@@ -415,8 +514,8 @@ n.a. - cls info method name methodName - cls ?object? info method name methodName +

List type of a method

@@ -428,12 +527,79 @@ n.a. - cls info method type methodName - cls ?object? info method type methodName + +

List the scope of mixin classes

+ + + + + + + + + + + + + + +
XOTcl 1XOTcl 2
cls info mixinof ?-closure? ?pattern?cls info mixinof -scope object ?-closure? ?pattern?
cls info instmixinof ?-closure? ?pattern?cls info mixinof -scope class ?-closure? ?pattern?
n.a.cls info mixinof -scope all ?-closure? ?pattern?
+

Check properties of object and classes

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl 1XOTcl 2
obj istype sometype + ::xotcl::is obj type sometype
+
+ obj info is type sometype +
obj ismixin cls + ::xotcl::is obj mixin cls
+
+ obj info is mixin cls +
obj isclass ?cls? + ::xotcl::is obj|cls class
+
+ obj info is class +
obj ismetaclass cls::xotcl::is obj|cls metaclass +
+ obj info is metaclass +
n.a.::xotcl::is cls baseclass +
+ cls info is baseclass +
obj isobject obj2::xotcl::is obj|obj2 object +
+ obj info is object +
+ +

Predefined Methods

Dispatch, Aliases, etc.

Assertions

@@ -479,7 +645,48 @@

Method Protection

+

Incompatibilities

+ +

Namespace resolvers

+

The XOTcl 2 namespace resolvers are use as well when XOTcl 1 is used +within XOTcl 2. +

+ +

Stronger Checking

+

XOTcl 2 performs stronger checking than XOTcl 1. The requiredness +of slots in XOTcl 1 was just a comment, while XOTcl 2 enforces it. +

+ +

Different results

+ + + + +

Exit handlers

+

+The exit hander interface changed from a method of +::xotcl::Object into procs in the ::xotcl +namespace. XOTcl 2 provides now: +

+   ::xotcl::setExitHandler script
+   ::xotcl::getExitHandler
+   ::xotcl::unsetExitHandler
+
+ +
- Last modified: Tue Jan 5 19:00:20 CET 2010 + Last modified: Tue Jan 12 11:35:29 CET 2010