Index: TODO =================================================================== diff -u -r264ccfcb835fd341d4fcb5e126d5305e073de0fc -r3d40cb4ba41cd488a5095695d7dcd8a6bd69efa9 --- TODO (.../TODO) (revision 264ccfcb835fd341d4fcb5e126d5305e073de0fc) +++ TODO (.../TODO) (revision 3d40cb4ba41cd488a5095695d7dcd8a6bd69efa9) @@ -1980,14 +1980,16 @@ {1} Class ::State {2} Class ::State -parameter x +- Converted migration guide to asciidoc +- Overhaul of serveral sections in asciidoc +- Developed styles for nx for migration guide (.css and source-highlight) - TODO: - "-returns" * handle "-returns" in serializer -- change allowempty to "orempty" or "empty" +- change allowempty to "empty" - extend coro regression test Index: doc/next-migration.html =================================================================== diff -u -raeed267ba4a296c7ec7808ed0b574cc76aecd35f -r3d40cb4ba41cd488a5095695d7dcd8a6bd69efa9 --- doc/next-migration.html (.../next-migration.html) (revision aeed267ba4a296c7ec7808ed0b574cc76aecd35f) +++ doc/next-migration.html (.../next-migration.html) (revision 3d40cb4ba41cd488a5095695d7dcd8a6bd69efa9) @@ -1,1484 +1,3695 @@ - - - -Migration Guide from XOTcl to the Next Scripting Language - - - - -

Migration Guide for the the Next Scripting Language

-

-... general text, maybe partly from slides/paper .... -TODO: Maybe we should not refer to ::nsf here and import instead -the "needed" commands into ::nx namespace. -

In general, the Next Scripting Language differs from XOTcl in the following -respects: - -

- -

Below is a small, introductory example showing an implementation of -a stack in nx and XOTcl. - -

-Class create Stack {
-
-   :method init {} {
-     set :things ""
-   } 
-
-   :public method push {thing} {
-      set :things [linsert ${:things} 0 $thing] 
-      return $thing
-   }
-  
-   :public method pop {} {
-      set top [lindex ${:things} 0]
-      set :things [lrange ${:things} 1 end]
-      return $top
-   }
-}
-
-

Figure 1: Stack example in the Next Scripting Language

- - -
-Class Stack
-
-Stack instproc init {} {
-   my instvar things
-   set things ""
-} 
-
-Stack instproc  push {thing} {
-   my instvar things
-   set things [linsert $things 0 $thing] 
-   return $thing
-}
-  
-Stack instproc pop {} {
-   my instvar things
-   set top [lindex $things 0]
-   set things [lrange $things 1 end]
-   return $top
-}
-
-

Figure 2: Stack example in XOTcl

- -

Using XOTcl 2.0 and the Next Scripting Language in the Next -Scripting Framework in a Single Interpreter

- -

In general, the Next Scripting Framework supports multiple object -systems concurrently. Effectively, every object system has different -base classes for creating objects and classes. Therefore, these object -systems can have different different interfaces and names of built-in -methods. Currently, the Next Scripting Framework supports primarily -XOTcl 2.0 (highly compatible with XOTcl 1.*) and the Next Scripting -Language (XOTcl provides about twice as many predefined built-in -methods compared to the Next Scripting Language).

- -

A single Tcl interpreter can host both, XOTcl and the Next -Scripting Language at the same time. This makes migration -from XOTcl to Next easier. The following example script shows to use -in a single script XOTcl and Next: -

- -

-   namespace eval mypackage {
-
-      package require XOTcl 2.0
-
-      # Import XOTcl into the current namespace
-      namespace import -force ::xotcl::*
-
-      # Define a class using XOTcl
-      Class C1
-      C1 instproc foo {} {puts "hello world"}
-
-      # Import Next into the current namespace
-      namespace import -force ::nx::*
-
-      # Define a class using Next
-      Class create C2 {
-         :public method foo {} {puts "hello world"}
-      }
-   }
-
- -

"Switching" between XOTcl and Next effectively means the load some -packages (if needed) and to import either the base classes -(Object and Class) of XOTcl or Next -into the current namespace.

- -

XOTcl Idioms in the Next Scripting Language

- -

Defining Objects and Classes

- - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
Class ClassNameClass create ClassName
Object ObjectNameObject create ObjectName
::xotcl::Class ClassName::nx::Class create ClassName
::xotcl::Object ObjectName::nx::Object create ObjectName
- -

Defining Methods

- -

Scripted Methods Defined in the Init-block of a Class/Object or with -Separate Calls

- - - - - - - - - - - -
XOTclNext Scripting Language
Class C
- C instproc foo args {...}
- C proc bar args {...}
-
- # Define method and class-object method
# in the init-block of a class


- Class create C {
-   :method foo args {...}
-   :class-object method bar args {...}
- }

- # Define method and class-object method with separate calls

- Class create C
- C method foo args {...}
- C class-object method bar args {...}
-
Object o
- o set x 1
- o proc foo args {...}
-
- # Define class-object method and set instance variable
- # in the init-block of an object


- Object create o {
-   set :x 1
-   :method foo args {...}
- }

- # Define class-object method and set instance variable
- # with separate commands


- Object create o
- o eval {set :x 1}
- o method foo args {...}
-
- -

Define Different Kinds of Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
- # Methods for defining methods:
#
- #     proc
- #     instproc
- #     forward
- #     instforward
- #     parametercmd
- #     instparametercmd
- #
- # All these methods return empty.
-
-
- # Methods for defining methods:
#
- #     method
- #     forward
- #     setter
- #     alias
- #     attribute
- #
- # All these methods return method-handles.
-
-
- Class C
- C instproc foo args {...}
- C proc bar args {...}

- Object o
- o proc baz args {...}
-
-
- # Define scripted methods

- Class create C {
-   :method foo args {...}
-   :class-object method bar args {...}
- }

- Object create o {
-   :method baz args {...}
- }
-
- Class C
- C instforward f1 ...
- C forward f2 ...

- Object o
- o forward f3 ...
-
-
- # Define forwarder

- Class create C {
-   :forward f1 ...
-   :class-object forward f2 ...
- }

- Object create o {
-   :forward f3 ...
- }
-
- Class C
- C instparametercmd p1
- C parametercmd p2

- Object o
- o parametercmd p3
-
-
- # Define setter and getter methods

- Class create C {
-   :setter p1 ?value_constraint?
-   :class-object setter p2 ?value_constraint?
- }

- Object create o {
-   :setter p3 ?value_constraint?
- }
-
- # Method "alias" not available

-
- # Define method aliases
# (to scripted or non-scripted methods)


- Class create C {
-   :alias a1 ...
-   :class-object alias a2 ...
- }

- Object create o {
-   :alias a3 ...
- }
-
- # Parameters only available at class level

- Class C \
   -parameter {
-     x
-     {y 1}
-
}
-
-
- # Define object attributes
# (parameters for initializing objects)


- Class create C {
-   :attribute x
-   :attribute {y 1}
-   :class-object attribute oa1
- }

- Object create o {
-   :attribute oa2
- }
-
- Class create C \
   -attributes {
-     x
-     {y 1}
-
}
-
- -

Method Modifiers and Method Protection

- - - - - - - - -
XOTclNext Scripting Language
# Method modifiers
- #
- #   "object",
- #   "public", and
- #   "protected"
- #
- # are not available.


-
- # Method modifiers orthogonal over all kinds of methods
- #
- # Method-definition-methods:
- #    method, forward, setter, alias, attribute -


- Class create C {
-   :method-definiton-method ...
-   :public method-definiton-method ...
-   :protected method-definiton-method ...
-   :class-object method-definiton-method ...
-   :protected class-object method-definiton-method ...
-   :public class-object method-definiton-method ...
- }
-
- -

The next scripting language allows to configure the default call -protection in various ways. The command ::nx::configure -defaultMethodCallProtection true|false can be used to set the -default call protection for scripted methods, forwarder and aliases, -while ::nx::configure defaultAttributeCallProtection -true|false can set the default for attributes and setters.

- - - -

Resolvers

- -The Next Scripting Framework defines Tcl resolvers for method and -variable names to refer to object specific behavior. Withing method -bodies these resolver treat variable and function names starting with -a colon ":" specially. In short, a colon-prefixed variable name refers -to an instance variable, and a colon-prefixed function name refers to -a method. The sub-sections below provide detailed examples. - -

Note that the Next resolvers can be used in the XOTcl 2.* environment -as well. - -

Invoking Methods

- - - - - - -
XOTclNext Scripting Language
Class C
- C instproc foo args {...}
- C instproc bar args {
-   my foo 1 2 3 ;# invoke own method
-   o baz       ;# invoke other objects method
- }
- Object o
- o proc baz {} {...}
-
Class create C {
-   :method foo args {...}
-   :method bar args {
-      :foo 1 2 3 ;# invoke own method
-      o baz     ;# invoke other objects method
-   }
- }
- Object create o {
-   :method baz {} {...}
- }
-
- - -

Accessing Own Instance Variables from Method Bodies

- -

In general, the Next Scripting Language favors the access to an -objects's own instance variables over variable accesses of other -objects. On the contrary, in XOTcl, the variable access to own and -other variables are completely symmetric. - -

In Next Scripting, access to local variables are performed via -primarily via name resolvers, but using the standard tcl commands -(like e.g. set, incr, append, -info exists, etc.). In XOTcl, it is common to provide -same-named methods registered on ::xotcl::Object for such -purposes. This is one of the reasons, why the Next Scripting Language -has a much smaller interface (less predefined methods). It is possible -for an application program to register XOTcl-like methods in the Next -Scripting Language via the primitives of the Next Scripting Framework. - -

- - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
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
-   }
- }
-
- ... instproc ... {
-    my set varname value
- } -
- # Set own instance variable to a value via - resolver
# (prefered and fastest way)


- - ... method ... {
-    set :newVar value
- } -
-
- ... instproc ... {
-    my instvar newVar
-    set newVar value
- } -
- # Set own instance variable via variable import

- - ... method ... {
-    ::nx::var import [self] varname
-    set varname value
- }
-
- - ... instproc ... {
-    set newVar [my set otherVar]
- } -
- # Read own instance variable

- - ... method ... {
-    set newVar [set :otherVar]
- } -


- - ... method ... {
-    set newVar ${:otherVar}
- } -
-
- ... instproc ... {
-    my exists varname
- } -
- # Test existence of own instance variable

- - ... method ... {
-    info :varname
- } -
-
- - ... method ... {
-    ::nx::var exists [self] varname
- }
-
- -

Accessing Instance Variables of other Objects

- - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj set varname value - # Set instance variable of object obj to a value via
- # resolver (prefered way: define setter method on obj)


- obj eval [list set :varname value]
set newVar [obj set otherVar] - # Read instance variable of object obj via resolver

- set newVar [obj eval {set :otherVar}]
-
- ... instproc ... {
-    obj instvar newVar
-    set newVar value
- }
-
- # Read instance variable of object obj via import

- - ... method ... {
-    ::nx::var import obj newVar
-    set newVar value
- }
-
obj exists varname - # Test existence of instance variable of - object obj

- obj eval {info exists :varname} -
- ::nx::var exists obj varname -
- - -

Object Parameters/Attributes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
Class Foo -parameter {a {b 1}}

- # Create instance of the class Foo
- Foo f1 -a 0

- # Object f1 has a == 0 and b == 1
-
- Class Foo -slots {
-    Attribute a
-    Attribute b -default 1
- }
-
- # Create instance of the class Foo
- Foo f1 -a 0

- # Object f1 has a == 0 and b == 1
-
-
- Class create Foo -attributes {a {b 1}}

- # Create instance of the class Foo
- Foo create f1 -a 0

- # Object f1 has a == 0 and b == 1
-
- Class create Foo {
-    :attribute a
-    :attribute {b 1}
- }

- # Create instance of the class Foo
- Foo create f1 -a 0

- # Object f1 has a == 0 and b == 1
-
-
- Class Person -slots {
-    Attribute create sex -type "sex" {
-      my proc type=sex {name value} {
-        switch -glob $value {
-          m* {return m}
-          f* {return f}
-          default {error "expected sex but got $value"}
-        }
-      }
-    }
- }
-
-
- Class create Person {
-    :attribute sex {
-      :type "sex"
-      :method type=sex {name value} {
-        switch -glob $value {
-          m* {return m}
-          f* {return f}
-          default {error "expected sex but got $value"}
-        }
-      }
-    }
- }
-
-
# Predefined value constraints for parameter not available - - # Predefined value constraints: object, class, - alnum, alpha,
- # ascii, boolean, control, digit, double, false, graph,
- # integer, lower, print, punct, space, true, upper,
- # wordchar, xdigit


- Class create Foo -attributes {
-    a:boolean
-    {b:integer 1}
- }
-
- Class create Foo {
-    :attribute a:boolean
-    :attribute {b:integer 1}
- }
-
-
# Required parameter not available - - # Required parameter
- Class create Foo -attributes {
-    a:boolean,required
-    {b:integer 1}
- }
-
- Class create Foo {
-    :attribute a:boolean,required
-    :attribute {b:integer 1}
- }
-
-
# Multivalued parameter not available - - # Required parameter
- Class create Foo -attributes {
-    ...
-    ints:integer,multivalued
-    {objs:object,multivalued ""}
- }
-
- Class create Foo {
-    ...
-    :attribute ints:integer,multivalued
-    :attribute {objs:object,multivalued ""}
- }
-
-
- - -## allowempty - -

Method Parameters

- -

Interceptors

- -

Register Mixin Classes and Mixin Guards

- - - - - - - - - - - - - - -
XOTclNext Scripting Language
cls instmixin ...
- cls instmixinguard mixin condition -
- # Register per-class mixin and guard for a class

- cls mixin ...
- cls mixin guard mixin condition -
- cls mixin ...
- cls mixin guard mixin condition -
- # Register per-object mixin and guard for a class

- cls class-object mixin ...
- cls class-object mixin guard mixin condition
-
- obj mixin ...
- obj mixinguard mixin condition -
- # Register per-object mixin and guard for an object

- obj mixin ...
- obj mixin guard mixin condition -
- - -

Register Filters and Filter Guards

- - - - - - - - - - - - - - -
XOTclNext Scripting Language
cls instfilter ...
- cls instfilterguard filter condition -
- # Register per-class filter and guard for a class

- cls filter ...
- cls filter guard filter condition -
- cls filter ...
- cls filterguard ... -
- # Register per-object filter and guard for a class

- cls class-object filter ...
- cls class-object filter guard filter condition
-
- obj filter ...
- obj filterguard filter condition -
- # Register per-object filter and guard for an - object

- obj filter ...
- obj filter guard filter condition -
- - - -

Introspection

- -

List methods defined by objects

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj info commands ?pattern?obj info methods ?pattern?
obj info parametercmd ?pattern?obj info methods -methodtype setter ?pattern?
obj info procs ?pattern?obj info methods -methodtype scripted ?pattern?
n.a.obj info methods -methodtype alias ?pattern?
n.a.obj info methods -methodtype forwarder ?pattern?
n.a.obj info methods -methodtype object ?pattern?
n.a.obj info methods -callprotection public|protected ...
-

List methods defined by classes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cls info instcommands ?pattern?cls info methods ?pattern?
cls info instparametercmd ?pattern?cls info methods -methodtype setter ?pattern?
cls info instprocs ?pattern?cls info methods -methodtype scripted ?pattern?
n.a.cls info methods -methodtype alias ?pattern?
n.a.cls info methods -methodtype forwarder ?pattern?
n.a.cls info methods -methodtype object ?pattern?
n.a.cls info methods -callprotection public|protected ...
- -

List class object specific methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cls info commands ?pattern?cls class-object info methods ?pattern?
cls info parametercmd ?pattern?cls class-object info methods -methodtype setter ?pattern?
cls info procs ?pattern?cls class-object info methods -methodtype scripted ?pattern?
n.a.cls class-object info methods -methodtype alias ?pattern?
n.a.cls class-object info methods -methodtype forwarder ?pattern?
n.a.cls class-object info methods -methodtype object ?pattern?
n.a.cls class-object info methods -callprotection public|protected ...
- -

List callable methods

- - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj info methods ?pattern?obj info lookup methods ... ?pattern?
- # Returns list of method names -
n.a.# List only application specific methods
- obj info lookup methods -source application ... ?pattern?
- # Returns list of method names -
# Options for 'info methods'
- #
- # -incontext
- # -nomixins
-
-
# Options for 'info lookup - methods'
- #
- # -source ...
- # -callprotection ...
- # -incontext
- # -methodtype ...
- # -nomixins
-
-
n.a.# List slot objects defined for obj
- obj info lookup slots
- # Returns list of slot objects -
- -

List object/class where some method is defined

- - - - - - - - - - - -
XOTclNext Scripting Language
obj procsearch methodNameobj info lookup method methodName
- # Returns method-handle
obj filtersearch methodNameobj info lookup filter methodName
- # Returns method-handle
- -

List definition of scripted methods defined by classes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
cls info instbody methodNamecls info method body methodName
cls info instargs methodNamecls info method args methodName
cls info instnonposargs methodNamecls info method parameter methodName
cls info instdefault methodNamecls info method parameter methodName
cls info instpre methodNamecls info method precondition methodName
cls info instpost methodNamecls info method postcondition methodName
n.a.cls info method definition methodName
- -

List definition of scripted object specific methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj info body methodNameobj info method body methodName
obj info args methodNameobj info method args methodName
obj info nonposargs methodNameobj info method parameter methodName
obj info default methodNameobj info method parameter methodName
obj info pre methodNameobj info method precondition methodName
obj info post methodNameobj info method postcondition methodName
n.a.obj info method definition methodName
-

For definition of class object specific methods, use modifier - object as shown in examples above. -

- -

List Filter or Mixins

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj info filter ?-guards? ?-order? ?pattern?# ... info filter methods -order ... returns method-handles
- # instead of triples (applies to all three variants)


- obj info filter methods ?-guards? ?-order? ?pattern?
obj info filterguard nameobj info filter guard name -
cls info filter ?-guards? ?-order? ?pattern?cls class-object info filter methods ?-guards? ?-order? ?pattern?
cls info filterguard namecls class-object info filter guard name
cls info instfilter ?-guards? ?-order? ?pattern?cls info filter methods ?-guards? ?-order? ?pattern?
cls info instfilterguard namecls info filter guard name
obj info mixin ?-guards? ?-order? ?pattern?obj info mixin classes ?-guards? ?-order? ?pattern?
obj info mixinguard nameobj info mixin guard name
cls info mixin ?-guards? ?-order? ?pattern?cls class-object info mixin classes ?-guards? ?-order? ?pattern?
cls info mixinguard namecls class-object info mixin guard name
cls info instmixin ?-guards? ?-order? ?pattern?cls info mixin classes ?-guards? ?-order? ?pattern?
cls info instmixinguard namecls info mixin guard name
- -

List definition of methods defined by aliases, setters or forwarders

- - - - - - - - - - -
XOTclNext Scripting Language
n.a.obj info method definition methodName
n.a.cls info method definition methodName
- -

List fully qualified name of method

- - - - - - - - - - -
XOTclNext Scripting Language
n.a.obj info method handle methodName
n.a.cls ?object? info method handle methodName
- -

List type of a method

- - - - - - - - - - -
XOTclNext Scripting Language
n.a.obj info method type methodName
n.a.cls ?object? info method type methodName
- -

List the scope of mixin classes

- - - - - - - - - - - - - - -
XOTclNext Scripting Language
cls info mixinof ?-closure? ?pattern? - # List objects, where cls is a per-object mixin

- cls info mixinof -scope object ?-closure? - ?pattern? -
cls info instmixinof ?-closure? ?pattern? - # List classes, where cls is a per-class mixin

- cls info mixinof -scope class ?-closure? - ?pattern? -
n.a. - # List objects and classes, where cls is
- # either a per-object or a per-class mixin


- cls info mixinof -scope all ?-closure? - ?pattern? -

- cls info mixinof ?-closure? ?pattern? -
- -

Check properties of object and classes

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj istype sometype - obj info has type sometype -
obj ismixin cls - obj info has mixin cls -
obj isclass ?cls? - obj info is class -
obj ismetaclass cls - obj info is metaclass -
n.a. - obj info is baseclass -
obj isobject obj2::nsf::isobject obj -
- -

Callstack Introspection

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
selfcurrent
-
- current object -
self classcurrent class
self proccurrent method
self callingclasscurrent currentclass
self callingobjectcurrent callingobject
self callingproccurrent callingmethod
self calledclasscurrent calledclass
self calledproccurrent calledmethod
self isnextcallcurrent isnextcall
self next# Returns method-handle
- current next
self filterreg# Returns method-handle
- current filterreg
self callinglevelcurrent callinglevel
self activelevelcurrent activelevel
- - -

Other Predefined Methods

- - - - - - - - -
XOTclNext Scripting Language
obj requireNamespaceobj require namespace
- - - -

Dispatch, Aliases, etc.

-

Assertions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XOTclNext Scripting Language
obj check checkoptions::nsf::assertion obj check checkptions
obj info check::nsf::assertion obj check
obj invar conditions::nsf::assertion obj object-invar conditions
obj info invar::nsf::assertion obj object-invar
cls instinvar conditions::nsf::assertion cls class-invar conditions
cls info instinvar::nsf::assertion cls class-invar
cls invar conditions::nsf::assertion cls object-invar conditions
cls info invar::nsf::assertion cls object-invar
-

Method Protection

- - -

Incompatibilities between XOTcl 1.* and XOTcl 2.0

- -

Resolvers

- -

The resolvers (variable resolvers, function resolvers) of the Next -Scripting Framework are used as well within XOTcl 2.0. When variable names -or method names starting with a single colon are used in XOTcl 1.* scripts, conflicts -will arise with the resolver. These names must be replaced.

- -

Calling objects via method interface

- -

Since the next framework supports the so-called ensemble objects, -which ease the definition of submethods substantially, objects -registered as methods have different semantics. In XOTcl 1.*, it was -possible to call e.g. a method foo of the slot object -Foo::slot::ints via the following two interfaces the same way: -

-Now, only the first form has the same semantic as before. In the second -form (invocation of objects via method interface) has now the ensemble object -semantics. This means that in the second case the current -obect of method foo is now Foo -instead of ints. - - -

Slots

- -

All slot objects (also XOTcl slot objects) are now next-scripting -objects of baseclass ::nx::Slot. The name of the -experimental default-setter initcmd was changed to -defaultcmd. Code directly working on the slots objects -has to be adapted.

- -

Obsolete commands

- -

Parameter-classes were rarely used and have been replaced by the more -general object parameterization. Therefore, cl info -parameterclass has been removed. - -

Stronger Checking

- -

The Next Scripting Framework performs stronger checking than XOTcl -1.*. For example, the requiredness of slots in XOTcl 1.* was just a -comment, while XOTcl 2.* enforces it.

- -

Exit Handlers

-

-The exit hander interface changed from a method of -::xotcl::Object into the tcl command ::nsf::exithandler: -

-   ::nsf::exithandler set|get|unset ?arg?
-
- - -
-
- Last modified: Fri Nov 26 18:45:03 CET 2010 - - + + + + + +Migration Guide for the the Next Scripting Language + + + + +
+
+
+
+
+
+
Abstract
+

This document describes the differences between the Next Scripting +Language Framework and XOTcl 1. In particular, it presents a +migration guide from XOTcl 1 to NX, and presents potential +incompatibilities beween XOTcl 1.and XOTcl 2

+
+
+
+
Todo
+

Here comes general text, maybe partly from slides/paper …. TODO: Maybe we +should not refer to ::nsf here, just to ::nx …

+
+
+
+
+

1. Differences Between XOTcl and NX

+
+

In general, the Next Scripting Language (NX) differs from XOTcl in +the following respects:

+
    +
  • +

    +The Next Scripting Language favors a stronger form of encapsulation + than XOTcl. Calling the own methods or accessing the + own instance variables is typographically easier and + computationally faster than these operations on other objects. This + behavior is achieved via resolvers an makes the definition of + methods necessary in XOTcl obsolete. On the other hand, XOTcl is + complete symmetrical in this respect. +

    +
  • +
  • +

    +The encapsulation of Next Scripting is still weak compared to + languages like C++; a developer can still access e.g. other + variables via some idioms, but this makes accesses to other + objects variables explicit and requires more typing + effort. Through the weak encapsulation a programmer should be + encouraged to implement methods to provide access to instance + variables. +

    +
  • +
  • +

    +The Next Scripting Language provides means of method protection. +

    +
  • +
  • +

    +The Next Scripting Language provides scripted init blocks for + objects and classes (replacement for the somewhat dangerous dash "-" + mechanism in XOTcl that allows to set variables and invoke methods + upon object creation). +

    +
  • +
  • +

    +The Next Scripting Language provides much more orthogonal means to + define, reuse and introspect scripted and C-implemented methods. +

    +
  • +
  • +

    +The Next Scripting Language provides an orthogonal framework for + parametrization of methods and objects. While XOTcl 1 provided only + value-checkers for non-positional arguments for methods, the Next Scripting + Framework provides the same value checkers for positional argument + of methods, as well as for object parameters (-parameter in XOTcl 1). +

    +
  • +
  • +

    +The Next Scripting Language has a much smaller interface (less + predefined methods) than XOTcl: +

    +
      +
    • +

      +NX: +

      +
      + + + + + + + + + + + + + + + + +
      +Methods for Objects: +
      +
      +

      +20 +

      +
      +Methods for Classes: +
      +
      +

      +7 +

      +
      +Info methods for Objects: +
      +
      +

      +14 +

      +
      +Info method for Classes: +
      +
      +

      +6 +

      +
      +
    • +
    • +

      +XOTcl: +

      +
      + + + + + + + + + + + + + + + + +
      +Methods for Objects: +
      +
      +

      +52 +

      +
      +Methods for Classes: +
      +
      +

      +24 +

      +
      +Info methods for Objects: +
      +
      +

      +25 +

      +
      +Info method for Classes: +
      +
      +

      +24 +

      +
      +
    • +
    +
  • +
+

Below is a small, introductory example showing an implementation of a stack in NX and XOTcl.

+
+ +++ + + + + + + + + + + + +
Stack example in NX Stack example in XOTcl
+
+
Class create Stack {
+
+   #
+   # Stack of Things
+   #
+
+   :method init {} {
+     set :things ""
+   }
+
+   :public method push {thing} {
+      set :things [linsert ${:things} 0 $thing]
+      return $thing
+   }
+
+   :public method pop {} {
+      set top [lindex ${:things} 0]
+      set :things [lrange ${:things} 1 end]
+      return $top
+   }
+}
+
+
#
+# Stack of Things
+#
+
+Class Stack
+
+Stack instproc init {} {
+   my instvar things
+   set things ""
+}
+
+Stack instproc  push {thing} {
+   my instvar things
+   set things [linsert $things 0 $thing]
+   return $thing
+}
+
+Stack instproc pop {} {
+   my instvar things
+   set top [lindex $things 0]
+   set things [lrange $things 1 end]
+}
+
+
+
+
+

2. Using XOTcl 2.0 and the Next Scripting Language in a Single Interpreter

+
+

In general, the Next Scripting Framework supports multiple object +systems concurrently. Effectively, every object system has different +base classes for creating objects and classes. Therefore, these object +systems can have different different interfaces and names of built-in +methods. Currently, the Next Scripting Framework is packaged with +three object systems:

+
    +
  • +

    +NX +

    +
  • +
  • +

    +XOTcl 2.0 +

    +
  • +
  • +

    +TclCool +

    +
  • +
+

XOTcl 2 is highly compatible with XOTcl 1, the language NX is +described below in more details, the language TclCool was introduced +in Tip#279 and serves primarily an example of a small OO language.

+

A single Tcl interpreter can host multiple Next Scripting Object +Systems at the same time. This fact makes migration from XOTcl to NX +easier. The following example script shows to use XOTcl and NX in a +single script:

+
+
Using Multiple Object Systems in a single Script
+
+
   namespace eval mypackage {
+
+      package require XOTcl 2.0
+
+      # Import XOTcl into the current namespace
+      namespace import -force ::xotcl::*
+
+      # Define a class using XOTcl
+      Class C1
+      C1 instproc foo {} {puts "hello world"}
+
+      package require nx
+
+      # Import NX into the current namespace;
+      # "Class" will be after the command "::nx::Class"
+      namespace import -force ::nx::*
+
+      # Define a class using NX
+      Class create C2 {
+         :public method foo {} {puts "hello world"}
+      }
+   }
+

One could certainly create object or classes from the different object +systems via fully qualified names (e.g. using e.g. ::xotcl::Class or +::nx::Class), but for migration for systems without explicit +namespaces switching between the object systems eases migration. +"Switching" between XOTcl and NX effectively means the load some +packages (if needed) and to import either the base classes (Object and +Class) of XOTcl or NX into the current namespace.

+
+
+
+

3. XOTcl Idioms in the Next Scripting Language

+
+
+

3.1. Defining Objects and Classes

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
Class ClassName
+
+
Class create ClassName
+
+
Object ObjectName
+
+
Object create ObjectName
+
+
+
+

3.2. Defining Methods

+
+

3.2.1. Scripted Methods Defined in the Init-block of a Class/Object or with Separate Calls

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
Class C
+C instproc foo args {...}
+C proc bar args {...}
+
+
# Define method and class-object method
+# in the init-block of a class
+
+Class create C {
+  :method foo args {...}
+  :class-object method bar args {...}
+}
+
+
+
# Define method and class-object method with separate calls
+
+Class create C
+C method foo args {...}
+C class-object method bar args {...}
+
+
Object o
+o set x 1
+o proc foo args {...}
+
+
# Define class-object method and set instance variable
+# in the init-block of an object
+
+Object create o {
+  set :x 1
+  :method foo args {...}
+}
+
+
+
# Define class-object method and set instance variable
+# with separate commands
+
+Object create o
+o eval {set :x 1}
+o method foo args {...}
+
+
+
+

3.2.2. Different Kinds of Methods

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
# Methods for defining methods:
+#
+#     proc
+#     instproc
+#     forward
+#     instforward
+#     parametercmd
+#     instparametercmd
+#
+# All these methods return empty.
+
+
# Methods for defining methods:
+#
+#     method
+#     forward
+#     setter
+#     alias
+#     attribute
+#
+# All these methods return method-handles.
+
+
Class C
+C instproc foo args {...}
+C proc bar args {...}
+
+Object o
+o proc baz args {...}
+
+
# Define scripted methods
+
+Class create C {
+  :method foo args {...}
+  :class-object method bar args {...}
+}
+
+Object create o {
+  :method baz args {...}
+}
+
+
Class C
+C instforward f1 ...
+C forward f2 ...
+
+Object o
+o forward f3 ...
+
+
# Define forwarder
+
+Class create C {
+  :forward f1 ...
+  :class-object forward f2 ...
+}
+
+Object create o {
+  :forward f3 ...
+}
+
+
Class C
+C instparametercmd p1
+C parametercmd p2
+
+Object o
+o parametercmd p3
+
+
# Define setter and getter methods
+
+Class create C {
+  :setter p1 ?value_constraint?
+  :class-object setter p2 ?value_constraint?
+}
+
+Object create o {
+  :setter p3 ?value_constraint?
+}
+
+
# Method "alias" not available
+
+
# Define method aliases
+# (to scripted or non-scripted methods)
+
+Class create C {
+  :alias a1 ...
+  :class-object alias a2 ...
+}
+
+Object create o {
+  :alias a3 ...
+}
+
+
# Parameters only available at class level
+
+Class C \
+   -parameter {
+    x
+    {y 1}
+}
+
+
# Define object attributes
+# (parameters for initializing objects)
+
+Class create C {
+  :attribute x
+  :attribute {y 1}
+  :class-object attribute oa1
+}
+
+Object create o {
+  :attribute oa2
+}
+
+
+
Class create C \
+   -attributes {
+    x
+    {y 1}
+}
+
+
+
+

3.2.3. Method Modifiers and Method Protection

+
+ +++ + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
# Method modifiers
+#
+#   "class-object",
+#   "public", and
+#   "protected"
+#
+# are not available
+
+
# Method modifiers orthogonal over all kinds of methods
+#
+# Method-definition-methods:
+#    method, forward, setter, alias, attribute
+
+Class create C {
+  :/method-definiton-method/ ...
+  :public /method-definiton-method/ ...
+  :protected /method-definiton-method/ ...
+  :class-object /method-definiton-method/ ...
+  :protected class-object /method-definiton-method/ ...
+  :public class-object /method-definiton-method/ ...
+}
+
+

The next scripting language allows to configure the default call +protection in various ways. The command +::nx::configure defaultMethodCallProtection true|false can be used to set the default +call protection for scripted methods, forwarder and aliases, while +::nx::configure defaultAttributeCallProtection true|false can set the +default for attributes and setters.

+
+
+
+

3.3. Resolvers

+

The Next Scripting Framework defines Tcl resolvers for method and +variable names to refer to object specific behavior. Within method +bodies these resolver treat variable and function names starting with +a colon : specially. In short, a colon-prefixed variable name refers +to an instance variable, and a colon-prefixed function name refers to +a method. The sub-sections below provide detailed examples.

+

Note that the Next resolvers can be used in the XOTcl 2.* environment as well.

+
+

3.3.1. Invoking Methods

+
+ +++ + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
Class C
+C instproc foo args {...}
+C instproc bar args {
+  my foo 1 2 3 ;# invoke own method
+  o baz        ;# invoke other objects method
+}
+Object o
+o proc baz {} {...}
+
+
Class create C {
+  :method foo args {...}
+  :method bar args {
+     :foo 1 2 3 ;# invoke own method
+     o baz      ;# invoke other objects method
+  }
+}
+Object create o {
+  :method baz {} {...}
+}
+
+
+
+

3.3.2. Accessing Own Instance Variables from Method Bodies

+

In general, the Next Scripting Language favors the access to an +objects’s own instance variables over variable accesses of other +objects. On the contrary, in XOTcl, the variable access to own and +other variables are completely symmetric.

+

In Next Scripting, access to local variables are performed via +primarily via name resolvers, but using the standard tcl commands +(like e.g. set, incr, append, info exists, etc.). In XOTcl, it +is common to provide same-named methods registered on +::xotcl::Object for such purposes. This is one of the reasons, why +the Next Scripting Language has a much smaller interface (less +predefined methods). It is possible for an application program to +register XOTcl-like methods in the Next Scripting Language via the +primitives of the Next Scripting Framework.

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
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
+  }
+}
+
+
... instproc ... {
+   my set /varName/ ?value?
+}
+
+
# Set own instance variable to a value via resolver
+# (preferred and fastest way)
+
+... method ... {
+   set /:newVar/ ?value?
+}
+
+
... instproc ... {
+   my instvar /varName/
+   set /varName/ ?value?
+}
+
+
# Set own instance variable via variable import
+
+... method ... {
+   ::nx::var import [self] /varName/
+   set /varName/ ?value?
+}
+
+
... instproc ... {
+   set /varName/ [my set /otherVar/]
+}
+
+
# Read own instance variable
+
+... method ... {
+   set /varName/ [set /:otherVar/]
+}
+
+
+
... method ... {
+   set /newVar/ ${/:otherVar/}
+}
+
+
... instproc ... {
+   my exists /varName/
+}
+
+
# Test existence of own instance variable
+
+... method ... {
+   info /:varName/
+}
+
+
+
 ... method ... {
+   ::nx::var exists [self] /varName/
+}
+
+
+
+

3.3.3. Accessing Instance Variables of other Objects

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ set /varName/ ?value?
+
+
# Set instance variable of object obj to a value via
+# resolver (preferred way: define setter method on obj)
+
+/obj/ eval [list set /:varName/ ?value?]
+
+
set /varName/ [/obj/ set /otherVar/]
+
+
# Read instance variable of object obj via resolver
+
+set /varName/ [/obj/ eval {set /:otherVar/}]
+
+
... instproc ... {
+   /obj/ instvar /varName/
+   set /varName/ ?value?
+}
+
+
# Read instance variable of object /obj/ via import
+
+... method ... {
+   ::nx::var import /obj/ /varName/
+   set /varName/ ?value?
+}
+
+
/obj/ exists varName
+
+
# Test existence of instance variable of object obj
+
+/obj/ eval {info exists /:varName/}
+
+
+
::nx::var exists /obj/ /varName/
+
+
+
+

3.3.4. Object Parameters/Attributes

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
Class Foo -parameter {a {b 1}}
+
+# Create instance of the class Foo
+Foo f1 -a 0
+
+# Object f1 has a == 0 and b == 1
+
+
+
Class Foo -slots {
+   Attribute a
+   Attribute b -default 1
+}
+
+# Create instance of the class Foo
+Foo f1 -a 0
+
+# Object f1 has a == 0 and b == 1
+
+
+
Class create Foo -attributes {a {b 1}}
+
+# Create instance of the class Foo
+Foo create f1 -a 0
+
+# Object f1 has a == 0 and b == 1
+
+
+
Class create Foo {
+   :attribute a
+   :attribute {b 1}
+}
+
+# Create instance of the class Foo
+Foo create f1 -a 0
+
+# Object f1 has a == 0 and b == 1
+
+
Class Person -slots {
+   Attribute create sex -type "sex" {
+     my proc type=sex {name value} {
+       switch -glob $value {
+         m* {return m}
+         f* {return f}
+         default {error "expected sex but got $value"}
+       }
+     }
+   }
+}
+
+
Class create Person {
+   :attribute sex {
+     :type "sex"
+     :method type=sex {name value} {
+       switch -glob $value {
+         m* {return m}
+         f* {return f}
+         default {error "expected sex but got $value"}
+       }
+     }
+   }
+}
+
+
# Predefined value constraints for parameter not available
+
+
# Predefined value constraints: object, class, alnum, alpha,
+# ascii, boolean, control, digit, double, false, graph,
+# integer, lower, print, punct, space, true, upper,
+# wordchar, xdigit
+
+Class create Foo -attributes {
+   a:boolean
+   {b:integer 1}
+}
+
+
+
Class create Foo {
+   :attribute a:boolean
+   :attribute {b:integer 1}
+}
+
+
# Required parameter not available
+
+
# Required parameter
+Class create Foo -attributes {
+   a:boolean,required
+   {b:integer 1}
+}
+
+
+

+Class create Foo {
+   :attribute a:boolean,required
+   :attribute {b:integer 1}
+}
+
+
# Multivalued parameter not available
+
+
# Required parameter
+Class create Foo -attributes {
+   ...
+   ints:integer,multivalued
+   {objs:object,multivalued ""}
+}
+
+
+
Class create Foo {
+   ...
+   :attribute ints:integer,multivalued
+   :attribute {objs:object,multivalued ""}
+}
+
+

## allowempty

+
+
+
+

3.4. Method Parameters

+

todo

+
+
+

3.5. Interceptors

+
+

3.5.1. Register Mixin Classes and Mixin Guards

+
+ +++ + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ instmixin ...
+/cls/ instmixinguard mixin /condition/
+
+
# Register per-class mixin and guard for a class
+
+/cls/ mixin ...
+/cls/ mixin guard mixin /condition/
+
+
/cls/ mixin ...
+/cls/ mixin guard mixin /condition/
+
+
# Register per-object mixin and guard for a class
+
+/cls/ class-object mixin ...
+/cls/ class-object mixin guard mixin /condition/
+
+
/obj/ mixin ...
+/obj/ mixinguard mixin /condition/
+
+
# Register per-object mixin and guard for an object
+
+/obj/ mixin ...
+/obj/ mixin guard mixin /condition/
+
+
+
+

3.5.2. Register Filters and Filter Guards

+
+ +++ + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ instfilter ...
+/cls/ instfilterguard filter /condition/
+
+
# Register per-class filter and guard for a class
+
+/cls/ filter ...
+/cls/ filter guard filter /condition/
+
+
/cls/ filter ...
+/cls/ filterguard ...
+
+
# Register per-object filter and guard for a class
+
+/cls/ class-object filter ...
+/cls/ class-object filter guard filter /condition/
+
+
/obj/ filter ...
+/obj/ filterguard filter /condition/
+
+
# Register per-object filter and guard for an object
+
+/obj/ filter ...
+/obj/ filter guard filter /condition/
+
+
+
+
+

3.6. Introspection

+
+

3.6.1. List methods defined by objects

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ info commands ?pattern?
+
+
/obj/ info methods ?pattern?
+
+
/obj/ info parametercmd ?pattern?
+
+
/obj/ info methods -methodtype setter ?pattern?
+
+
/obj/ info procs ?pattern?
+
+
/obj/ info methods -methodtype scripted ?pattern?
+
+
# n.a.
+
+
/obj/ info methods -methodtype alias ?pattern?
+
+
# n.a.
+
+
/obj/ info methods -methodtype forwarder ?pattern?
+
+
# n.a.
+
+
/obj/ info methods -methodtype object ?pattern?
+
+
# n.a.
+
+
/obj/ info methods -callprotection public|protected ...
+
+
+
+

3.6.2. List methods defined by classes

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ info instcommands ?pattern?
+
+
/cls/ info methods ?pattern?
+
+
/cls/ info instparametercmd ?pattern?
+
+
/cls/ info methods -methodtype setter ?pattern?
+
+
/cls/ info instprocs ?pattern?
+
+
/cls/ info methods -methodtype scripted ?pattern?
+
+
# n.a.
+
+
/cls/ info methods -methodtype alias ?pattern?
+
+
# n.a.
+
+
/cls/ info methods -methodtype forwarder ?pattern?
+
+
# n.a.
+
+
/cls/ info methods -methodtype object ?pattern?
+
+
# n.a.
+
+
/cls/ info methods -callprotection public|protected ...
+
+
+
+

3.6.3. List class object specific methods

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ info commands ?pattern?
+
+
/cls/ class-object info methods ?pattern?
+
+
/cls/ info parametercmd ?pattern?
+
+
/cls/ class-object info methods -methodtype setter ?pattern?
+
+
/cls/ info procs ?pattern?
+
+
/cls/ class-object info methods -methodtype scripted ?pattern?
+
+
# n.a.
+
+
/cls/ class-object info methods -methodtype alias ?pattern?
+
+
# n.a.
+
+
/cls/ class-object info methods -methodtype forwarder ?pattern?
+
+
# n.a.
+
+
/cls/ class-object info methods -methodtype object ?pattern?
+
+
# n.a.
+
+
/cls/ class-object info methods -callprotection public|protected ...
+
+
+
+

3.6.4. List callable methods

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ info methods ?pattern?
+
+
/obj/ info lookup methods ... ?pattern?
+# Returns list of method names
+
+
# n.a.
+
+
# List only application specific methods
+/obj/ info lookup methods -source application ... ?pattern?
+# Returns list of method names
+
+
# Options for 'info methods'
+#
+# -incontext
+# -nomixins
+
+
# Options for 'info lookup methods'
+#
+# -source ...
+# -callprotection ...
+# -incontext
+# -methodtype ...
+# -nomixins
+
+
# n.a.
+
+
# List slot objects defined for obj
+/obj/ info lookup slots
+# Returns list of slot objects
+
+
+
+

3.6.5. List object/class where some method is defined

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ procsearch /methodName/
+
+
/obj/ info lookup method /methodName/
+# Returns method-handle
+
+
/obj/ filtersearch /methodName/
+
+
/obj/ info lookup filter /methodName/
+# Returns method-handle
+
+
+
+

3.6.6. List definition of scripted methods defined by classes

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ info instbody /methodName/
+
+
/cls/ info method body /methodName/
+
+
/cls/ info instargs /methodName/
+
+
/cls/ info method args /methodName/
+
+
/cls/ info instnonposargs /methodName/
+
+
/cls/ info method parameter /methodName/
+
+
/cls/ info instdefault /methodName/
+
+
/cls/ info instdefault /methodName/
+
+
/cls/ info instpre /methodName/
+
+
/cls/ info method precondition /methodName/
+
+
/cls/ info instpost /methodName/
+
+
/cls/ info method postcondition /methodName/
+
+
# n.a.
+
+
/cls/ info method definition /methodName/
+
+
+
+

3.6.7. List definition of scripted object specific methods

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ info body /methodName/
+
+
/obj/ info method body /methodName/
+
+
/obj/ info args /methodName/
+
+
/obj/ info method args /methodName/
+
+
/obj/ info nonposargs /methodName/
+
+
/obj/ info method parameter /methodName/
+
+
/obj/ info default /methodName/
+
+
/obj/ info method parameter /methodName/
+
+
/obj/ info pre /methodName/
+
+
/obj/ info method precondition /methodName/
+
+
/obj/ info pre /methodName/
+
+
/obj/ info method precondition /methodName/
+
+
/obj/ info post /methodName/
+
+
/obj/ info post /methodName/
+
+
# n.a.
+
+
/obj/ info method definition /methodName/
+
+

For definition of class object specific methods, use modifier class-object as shown in examples above.

+
+
+

3.6.8. List Filter or Mixins

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ info filter ?-guards? ?-order? ?pattern?
+
+
# ... info filter methods -order ... returns method-handles
+# instead of triples (applies to all three variants)
+
+/obj/ info filter methods ?-guards? ?-order? ?pattern?
+
+
/obj/ info filterguard /name/
+
+
/obj/ info filter guard /name/
+
+
/cls/ info filter ?-guards? ?-order? ?pattern?
+
+
/cls/ class-object info filter methods ?-guards? ?-order? ?pattern?
+
+
/cls/ info filterguard /name/
+
+
/cls/ class-object info filter guard /name/
+
+
/cls/ info instfilter ?-guards? ?-order? ?pattern?
+
+
/cls/ info filter methods ?-guards? ?-order? ?pattern?
+
+
/cls/ info instfilterguard /name/
+
+
/cls/ info filter guard /name/
+
+
/obj/ info mixin ?-guards? ?-order? ?pattern?
+
+
/obj/ info mixin classes ?-guards? ?-order? ?pattern?
+
+
/obj/ info mixinguard /name/
+
+
/obj/ info mixin guard /name/
+
+
/cls/ info mixin ?-guards? ?-order? ?pattern?
+
+
/cls/ class-object info mixin classes ?-guards? ?-order? ?pattern?
+
+
/cls/ info mixinguard /name/
+
+
/cls/ class-object info mixin guard /name/
+
+
/cls/ info instmixin ?-guards? ?-order? ?pattern?
+
+
/cls/ info mixin classes ?-guards? ?-order? ?pattern?
+
+
/cls/ info instmixinguard /name/
+
+
/cls/ info mixin guard /name/
+
+
+
+

3.6.9. List definition of methods defined by aliases, setters or forwarders

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
# n.a.
+
+
/obj/ info method definition /methodName/
+
+
# n.a.
+
+
/cls/ info method definition /methodName/
+
+
+
+

3.6.10. List fully qualified name of method

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
# n.a.
+
+
/obj/ info method handle /methodName/
+
+
# n.a.
+
+
/cls/ ?class-object? info method handle /methodName/
+
+
+
+

3.6.11. List type of a method

+
+ +++ + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
# n.a.
+
+
/obj/ info method type /methodName/
+
+
# n.a.
+
+
/cls/ ?class-object? info method type /methodName/
+
+
+
+

3.6.12. List the scope of mixin classes

+
+ +++ + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/cls/ info mixinof ?-closure? ?pattern?
+
+
# List objects, where /cls/ is a per-object mixin
+
+/cls/ info mixinof -scope object ?-closure? ?pattern?
+
+
/cls/ info instmixinof ?-closure? ?pattern?
+
+
# List classes, where /cls/ is a per-class mixin
+
+/cls/ info mixinof -scope class ?-closure? ?pattern?
+
+
# n.a.
+
+
# List objects and classes, where /cls/ is
+# either a per-object or a per-class mixin
+
+/cls/ info mixinof -scope all ?-closure? ?pattern?
+
+
+
/cls/ info mixinof ?-closure? ?pattern?
+
+
+
+

3.6.13. Check properties of object and classes

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ istype /sometype/
+
+
/obj/ info has type /sometype/
+
+
/obj/ ismixin /cls/
+
+
/obj/ info has mixin /cls/
+
+
/obj/ isclass ?/cls/?
+
+
/obj/ info is class
+
+
/obj/ ismetaclass /cls/
+
+
/obj/ info is metaclass
+
+
# n.a.
+
+
/obj/ info is baseclass
+
+
/obj/ isobject /obj/
+
+
::nsf::isobject /obj/
+
+
+
+

3.6.14. Call-stack Introspection

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
self
+
+
current
+
+
+
current object
+
+
self class
+
+
current class
+
+
self proc
+
+
current method
+
+
self callingclass
+
+
current currentclass
+
+
self callingobject
+
+
current callingobject
+
+
self callingproc
+
+
current callingmethod
+
+
self calledclass
+
+
current calledclass
+
+
self calledproc
+
+
current calledmethod
+
+
self isnextcall
+
+
current isnextcall
+
+
self next
+
+
# Returns method-handle
+current next
+
+
self filterreg
+
+
# Returns method-handle
+current filterreg
+
+
self callinglevel
+
+
current callinglevel
+
+
self activelevel
+
+
current activelevel
+
+
+
+
+

3.7. Other Predefined Methods

+
+ +++ + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ requireNamespace
+
+
/obj/ require namespace
+
+
+
+

3.8. Dispatch, Aliases, etc.

+

todo: to be done or omitted

+
+
+

3.9. Assertions

+
+ +++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XOTcl Next Scripting Language
+
+
/obj/ check /checkoptions/
+
+
::nsf::assertion /obj/ check /checkptions/
+
+
/obj/ info check
+
+
::nsf::assertion /obj/ check
+
+
/obj/ invar /conditions/
+
+
::nsf::assertion /obj/ object-invar /conditions/
+
+
/obj/ info invar
+
+
::nsf::assertion /obj/ object-invar
+
+
/cls/ instinvar /conditions/
+
+
::nsf::assertion /cls/ class-invar /conditions/
+
+
/cls/ info instinvar
+
+
::nsf::assertion /cls/ class-invar
+
+
/cls/ invar /conditions/
+
+
::nsf::assertion /cls/ object-invar /conditions/
+
+
/cls/ info invar
+
+
::nsf::assertion /cls/ object-invar
+
+
+
+

3.10. Method Protection

+

As described above, NX supports method +protection via the method modifiers protected and public. A +protected method can be only called from an object of that class, +while public methods can be called from every object. The method +protection can be used to every kind of method, such as e.g. scripted +methods, aliases, forwarders, setters or attributes. For invocations, +the most specific definition (might be a mixin) is used for +determining the protection.

+
+
+
+
+

4. Incompatibilities between XOTcl 1 and XOTcl 2

+
+
+

4.1. Resolvers

+

The resolvers (variable resolvers, function resolvers) of the Next +Scripting Framework are used as well within XOTcl 2. When variable +names or method names starting with a single colon are used in XOTcl 1 +scripts, conflicts will arise with the resolver. These names must be +replaced.

+
+
+

4.2. Parameters

+

The following changes for parameters could be regarded as bug-fixes.

+
+

4.2.1. Parameter usage without a value

+

In XOTcl 1, it was possible to call a parameter method during object +creation via the -param without a value (in the example below -x.

+
+
+
Class Foo -parameter {x y}
+Foo f1 -x -y 1
+

Such cases are most likely mistakes. All parameter configurations in XOTcl 2 require an argument.

+
+
+

4.2.2. Ignored Parameter definitions

+

In XOTcl 1, a more specific parameter definition without a default was ignored +when a more general parameter definition with a default was +present. In the example below, the object b1 contained in XOTcl 1 +incorrectly the parameter x (set via default from Foo), while in +XOTcl 2, the variable won’t be set.

+
+
+
Class Foo -parameter {{x 1}}
+Class Bar -superclass Foo -parameter x
+Bar b1
+
+
+
+

4.3. Calling objects via method interface

+

Since the Next Scripting Framework supports the so-called ensemble +objects, which ease the definition of sub-methods substantially, +objects registered as methods have different semantics. In XOTcl 1, it +was possible to call e.g. a method foo of the slot object +Foo::slot::ints via the following two interfaces the same way:

+
+
+
Foo::slot::ints foo ...
+Foo slot ints foo ...
+

In the Next Scripting Framework, only the first form has the same +semantic as before. In the second form (invocation of objects via +method interface) has now the ensemble object semantics. This means +that in the second case the current object of method foo is now Foo +instead of ints.

+
+
+

4.4. Slots

+

All slot objects (also XOTcl slot objects) are now next-scripting +objects of baseclass ::nx::Slot. The name of the experimental +default-setter initcmd was changed to defaultcmd. Code directly +working on the slots objects has to be adapted.

+
+
+

4.5. Obsolete commands

+

Parameter-classes were rarely used and have been replaced by the more +general object parameterization. Therefore, cl info parameterclass has +been removed.

+
+
+

4.6. Stronger Checking

+

The Next Scripting Framework performs stronger checking than XOTcl 1 +For example, the requiredness of slots in XOTcl 1 was just a +comment, while XOTcl 2 enforces it.

+
+
+

4.7. Exit Handlers

+

The exit hander interface changed from a method of ::xotcl::Object +into the Tcl command ::nsf::exithandler:

+
+
+
::nsf::exithandler set|get|unset ?arg?
+
+
+
+
+

+ + + Index: doc/next-migration.txt =================================================================== diff -u --- doc/next-migration.txt (revision 0) +++ doc/next-migration.txt (revision 3d40cb4ba41cd488a5095695d7dcd8a6bd69efa9) @@ -0,0 +1,1955 @@ +Migration Guide for the the Next Scripting Language +==================================================== +Gustaf Neumann +v2.0, December 2010: +Written for the Initial Release of the Next Scripting Framework. +:Author Initials: GN +:toc: +:icons: +:numbered: +:website: http://www.xotcl.org/ + +.Abstract +***************************************************************************** +This document describes the differences between the Next Scripting +Language Framework and XOTcl 1. In particular, it presents a +migration guide from XOTcl 1 to NX, and presents potential +incompatibilities beween XOTcl 1.and XOTcl 2 +***************************************************************************** + + +.Todo +***************************************************************************** +Here comes general text, maybe partly from slides/paper .... TODO: Maybe we +should not refer to ::nsf here, just to ::nx ... +***************************************************************************** + + +Differences Between XOTcl and NX +------------------------------- + +In general, the Next Scripting Language (NX) differs from XOTcl in +the following respects: + +- The Next Scripting Language favors a _stronger form of encapsulation_ + than XOTcl. Calling the own methods or accessing the + own instance variables is typographically easier and + computationally faster than these operations on other objects. This + behavior is achieved via resolvers an makes the definition of + methods necessary in XOTcl obsolete. On the other hand, XOTcl is + complete symmetrical in this respect. + +- The encapsulation of Next Scripting is still weak compared to + languages like C++; a developer can still access e.g. other + variables via some idioms, but this _makes accesses to other + objects variables explicit_ and requires more typing + effort. Through the weak encapsulation a programmer should be + encouraged to implement methods to provide access to instance + variables. + +- The Next Scripting Language provides means of _method protection_. + +- The Next Scripting Language provides _scripted init blocks_ for + objects and classes (replacement for the somewhat dangerous dash "-" + mechanism in XOTcl that allows to set variables and invoke methods + upon object creation). + +- The Next Scripting Language provides much more orthogonal means to + _define, reuse and introspect scripted and C-implemented methods_. + +- The Next Scripting Language provides an _orthogonal framework for + parametrization of methods and objects_. While XOTcl 1 provided only + value-checkers for non-positional arguments for methods, the Next Scripting + Framework provides the same value checkers for positional argument + of methods, as well as for object parameters (`-parameter` in XOTcl 1). + +- The Next Scripting Language has a much _smaller interface_ (less + predefined methods) than XOTcl: + + * NX: +[horizontal] +Methods for Objects: :: 20 +Methods for Classes: :: 7 +Info methods for Objects: :: 14 +Info method for Classes: :: 6 + + * XOTcl: +[horizontal] +Methods for Objects: :: 52 +Methods for Classes: :: 24 +Info methods for Objects: :: 25 +Info method for Classes: :: 24 + +Below is a small, introductory example showing an implementation of a stack in NX and XOTcl. + +[options="header",cols="asciidoc,asciidoc",frame="none"] +|====================== +|Stack example in NX |Stack example in XOTcl +|[source,tcl] +-------------------------------------------------- +Class create Stack { + + # + # Stack of Things + # + + :method init {} { + set :things "" + } + + :public method push {thing} { + set :things [linsert ${:things} 0 $thing] + return $thing + } + + :public method pop {} { + set top [lindex ${:things} 0] + set :things [lrange ${:things} 1 end] + return $top + } +} +-------------------------------------------------- +|[source,tcl] +-------------------------------------------------- +# +# Stack of Things +# + +Class Stack + +Stack instproc init {} { + my instvar things + set things "" +} + +Stack instproc push {thing} { + my instvar things + set things [linsert $things 0 $thing] + return $thing +} + +Stack instproc pop {} { + my instvar things + set top [lindex $things 0] + set things [lrange $things 1 end] +} +-------------------------------------------------- +|====================== + +Using XOTcl 2.0 and the Next Scripting Language in a Single Interpreter +--------------------------------------------------------------------- + +In general, the Next Scripting Framework supports multiple object +systems concurrently. Effectively, every object system has different +base classes for creating objects and classes. Therefore, these object +systems can have different different interfaces and names of built-in +methods. Currently, the Next Scripting Framework is packaged with +three object systems: + +- NX +- XOTcl 2.0 +- TclCool + +XOTcl 2 is highly compatible with XOTcl 1, the language NX is +described below in more details, the language TclCool was introduced +in Tip#279 and serves primarily an example of a small OO language. + +A single Tcl interpreter can host multiple Next Scripting Object +Systems at the same time. This fact makes migration from XOTcl to NX +easier. The following example script shows to use XOTcl and NX in a +single script: + +.Using Multiple Object Systems in a single Script +[source,tcl] +-------------------------------------------------- + namespace eval mypackage { + + package require XOTcl 2.0 + + # Import XOTcl into the current namespace + namespace import -force ::xotcl::* + + # Define a class using XOTcl + Class C1 + C1 instproc foo {} {puts "hello world"} + + package require nx + + # Import NX into the current namespace; + # "Class" will be after the command "::nx::Class" + namespace import -force ::nx::* + + # Define a class using NX + Class create C2 { + :public method foo {} {puts "hello world"} + } + } +-------------------------------------------------- + +One could certainly create object or classes from the different object +systems via fully qualified names (e.g. using e.g. `::xotcl::Class` or +`::nx::Class`), but for migration for systems without explicit +namespaces switching between the object systems eases migration. +"Switching" between XOTcl and NX effectively means the load some +packages (if needed) and to import either the base classes (Object and +Class) of XOTcl or NX into the current namespace. + +XOTcl Idioms in the Next Scripting Language +--------------------------------------------- + +Defining Objects and Classes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +Class ClassName +---------------- +|[source,tcl] +---------------- +Class create ClassName +---------------- + +|[source,tcl] +---------------- +Object ObjectName +---------------- +|[source,tcl] +---------------- +Object create ObjectName +---------------- +|=========================== + + +Defining Methods +~~~~~~~~~~~~~~~~ + +==== Scripted Methods Defined in the Init-block of a Class/Object or with Separate Calls +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +Class C +C instproc foo args {...} +C proc bar args {...} +---------------- +|[source,tcl] +---------------- +# Define method and class-object method +# in the init-block of a class + +Class create C { + :method foo args {...} + :class-object method bar args {...} +} +---------------- +[source,tcl] +---------------- +# Define method and class-object method with separate calls + +Class create C +C method foo args {...} +C class-object method bar args {...} +---------------- + +|[source,tcl] +---------------- +Object o +o set x 1 +o proc foo args {...} +---------------- + +|[source,tcl] +---------------- +# Define class-object method and set instance variable +# in the init-block of an object + +Object create o { + set :x 1 + :method foo args {...} +} +---------------- +[source,tcl] +---------------- +# Define class-object method and set instance variable +# with separate commands + +Object create o +o eval {set :x 1} +o method foo args {...} +---------------- +|=========================== + +==== Different Kinds of Methods +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +# Methods for defining methods: +# +# proc +# instproc +# forward +# instforward +# parametercmd +# instparametercmd +# +# All these methods return empty. +---------------- + +|[source,tcl] +---------------- +# Methods for defining methods: +# +# method +# forward +# setter +# alias +# attribute +# +# All these methods return method-handles. +---------------- + +|[source,tcl] +---------------- +Class C +C instproc foo args {...} +C proc bar args {...} + +Object o +o proc baz args {...} +---------------- + +|[source,tcl] +---------------- +# Define scripted methods + +Class create C { + :method foo args {...} + :class-object method bar args {...} +} + +Object create o { + :method baz args {...} +} +---------------- + +|[source,tcl] +---------------- +Class C +C instforward f1 ... +C forward f2 ... + +Object o +o forward f3 ... +---------------- + +|[source,tcl] +---------------- +# Define forwarder + +Class create C { + :forward f1 ... + :class-object forward f2 ... +} + +Object create o { + :forward f3 ... +} +---------------- + +|[source,tcl] +---------------- +Class C +C instparametercmd p1 +C parametercmd p2 + +Object o +o parametercmd p3 +---------------- + +|[source,tcl] +---------------- +# Define setter and getter methods + +Class create C { + :setter p1 ?value_constraint? + :class-object setter p2 ?value_constraint? +} + +Object create o { + :setter p3 ?value_constraint? +} +---------------- + + +|[source,tcl] +---------------- +# Method "alias" not available +---------------- + +|[source,tcl] +---------------- +# Define method aliases +# (to scripted or non-scripted methods) + +Class create C { + :alias a1 ... + :class-object alias a2 ... +} + +Object create o { + :alias a3 ... +} +---------------- + +|[source,tcl] +---------------- +# Parameters only available at class level + +Class C \ + -parameter { + x + {y 1} +} +---------------- + +|[source,tcl] +---------------- +# Define object attributes +# (parameters for initializing objects) + +Class create C { + :attribute x + :attribute {y 1} + :class-object attribute oa1 +} + +Object create o { + :attribute oa2 +} +---------------- +[source,tcl] +---------------- +Class create C \ + -attributes { + x + {y 1} +} +---------------- +|=========================== + + +[[method-protect-example]] +==== Method Modifiers and Method Protection + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +# Method modifiers +# +# "class-object", +# "public", and +# "protected" +# +# are not available +---------------- +|[source,tcl] +---------------- +# Method modifiers orthogonal over all kinds of methods +# +# Method-definition-methods: +# method, forward, setter, alias, attribute + +Class create C { + :/method-definiton-method/ ... + :public /method-definiton-method/ ... + :protected /method-definiton-method/ ... + :class-object /method-definiton-method/ ... + :protected class-object /method-definiton-method/ ... + :public class-object /method-definiton-method/ ... +} +---------------- +|====================== + +The next scripting language allows to configure the default call +protection in various ways. The command +`::nx::configure defaultMethodCallProtection true|false` can be used to set the default +call protection for scripted methods, forwarder and aliases, while +`::nx::configure defaultAttributeCallProtection true|false` can set the +default for attributes and setters. + + +=== Resolvers + +The Next Scripting Framework defines Tcl resolvers for method and +variable names to refer to object specific behavior. Within method +bodies these resolver treat variable and function names starting with +a colon `:` specially. In short, a colon-prefixed variable name refers +to an instance variable, and a colon-prefixed function name refers to +a method. The sub-sections below provide detailed examples. + +Note that the Next resolvers can be used in the XOTcl 2.* environment as well. + + +==== Invoking Methods +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +Class C +C instproc foo args {...} +C instproc bar args { + my foo 1 2 3 ;# invoke own method + o baz ;# invoke other objects method +} +Object o +o proc baz {} {...} +---------------- +|[source,tcl] +---------------- +Class create C { + :method foo args {...} + :method bar args { + :foo 1 2 3 ;# invoke own method + o baz ;# invoke other objects method + } +} +Object create o { + :method baz {} {...} +} +---------------- +|====================== + + +==== Accessing Own Instance Variables from Method Bodies + +In general, the Next Scripting Language favors the access to an +objects's own instance variables over variable accesses of other +objects. On the contrary, in XOTcl, the variable access to own and +other variables are completely symmetric. + +In Next Scripting, access to local variables are performed via +primarily via name resolvers, but using the standard tcl commands +(like e.g. `set`, `incr`, `append`, `info exists`, etc.). In XOTcl, it +is common to provide same-named methods registered on +`::xotcl::Object` for such purposes. This is one of the reasons, why +the Next Scripting Language has a much smaller interface (less +predefined methods). It is possible for an application program to +register XOTcl-like methods in the Next Scripting Language via the +primitives of the Next Scripting Framework. + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +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 +} +---------------- +|[source,tcl] +---------------- +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 + } +} +---------------- +|[source,tcl] +---------------- +... instproc ... { + my set /varName/ ?value? +} +---------------- +|[source,tcl] +---------------- +# Set own instance variable to a value via resolver +# (preferred and fastest way) + +... method ... { + set /:newVar/ ?value? +} +---------------- +|[source,tcl] +---------------- +... instproc ... { + my instvar /varName/ + set /varName/ ?value? +} +---------------- +|[source,tcl] +---------------- +# Set own instance variable via variable import + +... method ... { + ::nx::var import [self] /varName/ + set /varName/ ?value? +} +---------------- +|[source,tcl] +---------------- +... instproc ... { + set /varName/ [my set /otherVar/] +} +---------------- +|[source,tcl] +---------------- +# Read own instance variable + +... method ... { + set /varName/ [set /:otherVar/] +} +---------------- +[source,tcl] +---------------- +... method ... { + set /newVar/ ${/:otherVar/} +} +---------------- +|[source,tcl] +---------------- +... instproc ... { + my exists /varName/ +} +---------------- +|[source,tcl] +---------------- +# Test existence of own instance variable + +... method ... { + info /:varName/ +} +---------------- +[source,tcl] +---------------- + ... method ... { + ::nx::var exists [self] /varName/ +} +---------------- +|====================== + +==== Accessing Instance Variables of other Objects + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ set /varName/ ?value? +---------------- +|[source,tcl] +---------------- +# Set instance variable of object obj to a value via +# resolver (preferred way: define setter method on obj) + +/obj/ eval [list set /:varName/ ?value?] +---------------- +|[source,tcl] +---------------- +set /varName/ [/obj/ set /otherVar/] +---------------- +|[source,tcl] +---------------- +# Read instance variable of object obj via resolver + +set /varName/ [/obj/ eval {set /:otherVar/}] +---------------- +|[source,tcl] +---------------- +... instproc ... { + /obj/ instvar /varName/ + set /varName/ ?value? +} +---------------- +|[source,tcl] +---------------- +# Read instance variable of object /obj/ via import + +... method ... { + ::nx::var import /obj/ /varName/ + set /varName/ ?value? +} +---------------- +|[source,tcl] +---------------- +/obj/ exists varName +---------------- +|[source,tcl] +---------------- +# Test existence of instance variable of object obj + +/obj/ eval {info exists /:varName/} +---------------- +[source,tcl] +---------------- +::nx::var exists /obj/ /varName/ +---------------- +|====================== + +==== Object Parameters/Attributes + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +Class Foo -parameter {a {b 1}} + +# Create instance of the class Foo +Foo f1 -a 0 + +# Object f1 has a == 0 and b == 1 +---------------- +[source,tcl] +---------------- +Class Foo -slots { + Attribute a + Attribute b -default 1 +} + +# Create instance of the class Foo +Foo f1 -a 0 + +# Object f1 has a == 0 and b == 1 + +---------------- +|[source,tcl] +---------------- +Class create Foo -attributes {a {b 1}} + +# Create instance of the class Foo +Foo create f1 -a 0 + +# Object f1 has a == 0 and b == 1 +---------------- +[source,tcl] +---------------- +Class create Foo { + :attribute a + :attribute {b 1} +} + +# Create instance of the class Foo +Foo create f1 -a 0 + +# Object f1 has a == 0 and b == 1 +---------------- +|[source,tcl] +---------------- +Class Person -slots { + Attribute create sex -type "sex" { + my proc type=sex {name value} { + switch -glob $value { + m* {return m} + f* {return f} + default {error "expected sex but got $value"} + } + } + } +} +---------------- +|[source,tcl] +---------------- +Class create Person { + :attribute sex { + :type "sex" + :method type=sex {name value} { + switch -glob $value { + m* {return m} + f* {return f} + default {error "expected sex but got $value"} + } + } + } +} +---------------- +|[source,tcl] +---------------- +# Predefined value constraints for parameter not available +---------------- +|[source,tcl] +---------------- +# Predefined value constraints: object, class, alnum, alpha, +# ascii, boolean, control, digit, double, false, graph, +# integer, lower, print, punct, space, true, upper, +# wordchar, xdigit + +Class create Foo -attributes { + a:boolean + {b:integer 1} +} +---------------- +[source,tcl] +---------------- +Class create Foo { + :attribute a:boolean + :attribute {b:integer 1} +} +---------------- +|[source,tcl] +---------------- +# Required parameter not available +---------------- +|[source,tcl] +---------------- +# Required parameter +Class create Foo -attributes { + a:boolean,required + {b:integer 1} +} +---------------- +[source,tcl] +---------------- + +Class create Foo { + :attribute a:boolean,required + :attribute {b:integer 1} +} +---------------- +|[source,tcl] +--------------- +# Multivalued parameter not available +----------------- +|[source,tcl] +---------------- +# Required parameter +Class create Foo -attributes { + ... + ints:integer,multivalued + {objs:object,multivalued ""} +} +---------------- +[source,tcl] +---------------- +Class create Foo { + ... + :attribute ints:integer,multivalued + :attribute {objs:object,multivalued ""} +} +---------------- +|====================== +## allowempty + +=== Method Parameters + +todo + +=== Interceptors + +==== Register Mixin Classes and Mixin Guards + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ instmixin ... +/cls/ instmixinguard mixin /condition/ +---------------- +|[source,tcl] +---------------- +# Register per-class mixin and guard for a class + +/cls/ mixin ... +/cls/ mixin guard mixin /condition/ +---------------- +|[source,tcl] +---------------- +/cls/ mixin ... +/cls/ mixin guard mixin /condition/ +---------------- +|[source,tcl] +---------------- +# Register per-object mixin and guard for a class + +/cls/ class-object mixin ... +/cls/ class-object mixin guard mixin /condition/ +---------------- +|[source,tcl] +---------------- +/obj/ mixin ... +/obj/ mixinguard mixin /condition/ +---------------- +|[source,tcl] +---------------- +# Register per-object mixin and guard for an object + +/obj/ mixin ... +/obj/ mixin guard mixin /condition/ +---------------- +|====================== + +==== Register Filters and Filter Guards +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ instfilter ... +/cls/ instfilterguard filter /condition/ +---------------- +|[source,tcl] +---------------- +# Register per-class filter and guard for a class + +/cls/ filter ... +/cls/ filter guard filter /condition/ +---------------- +|[source,tcl] +---------------- +/cls/ filter ... +/cls/ filterguard ... +---------------- +|[source,tcl] +---------------- +# Register per-object filter and guard for a class + +/cls/ class-object filter ... +/cls/ class-object filter guard filter /condition/ +---------------- +|[source,tcl] +---------------- +/obj/ filter ... +/obj/ filterguard filter /condition/ +---------------- +|[source,tcl] +---------------- +# Register per-object filter and guard for an object + +/obj/ filter ... +/obj/ filter guard filter /condition/ +---------------- +|====================== + +=== Introspection +==== List methods defined by objects +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ info commands ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info methods ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info parametercmd ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info methods -methodtype setter ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info procs ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info methods -methodtype scripted ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info methods -methodtype alias ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info methods -methodtype forwarder ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info methods -methodtype object ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info methods -callprotection public\|protected ... +---------------- +|====================== + +==== List methods defined by classes + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ info instcommands ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info methods ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info instparametercmd ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info methods -methodtype setter ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info instprocs ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info methods -methodtype scripted ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ info methods -methodtype alias ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ info methods -methodtype forwarder ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ info methods -methodtype object ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ info methods -callprotection public\|protected ... +---------------- +|====================== + +==== List class object specific methods + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ info commands ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info parametercmd ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -methodtype setter ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info procs ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -methodtype scripted ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -methodtype alias ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -methodtype forwarder ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -methodtype object ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ class-object info methods -callprotection public\|protected ... +---------------- +|====================== + +==== List callable methods + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ info methods ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info lookup methods ... ?pattern? +# Returns list of method names +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +# List only application specific methods +/obj/ info lookup methods -source application ... ?pattern? +# Returns list of method names +---------------- +|[source,tcl] +---------------- +# Options for 'info methods' +# +# -incontext +# -nomixins +---------------- +|[source,tcl] +---------------- +# Options for 'info lookup methods' +# +# -source ... +# -callprotection ... +# -incontext +# -methodtype ... +# -nomixins +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +# List slot objects defined for obj +/obj/ info lookup slots +# Returns list of slot objects +---------------- +|====================== + +==== List object/class where some method is defined + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ procsearch /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info lookup method /methodName/ +# Returns method-handle +---------------- +|[source,tcl] +---------------- +/obj/ filtersearch /methodName/ +---------------- +|[source,tcl] +--------------- +/obj/ info lookup filter /methodName/ +# Returns method-handle +----------------- +|====================== + +==== List definition of scripted methods defined by classes + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ info instbody /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info method body /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instargs /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info method args /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instnonposargs /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info method parameter /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instdefault /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instdefault /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instpre /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info method precondition /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info instpost /methodName/ +---------------- +|[source,tcl] +---------------- +/cls/ info method postcondition /methodName/ +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ info method definition /methodName/ +---------------- +|====================== + +==== List definition of scripted object specific methods + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ info body /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info method body /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info args /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info method args /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info nonposargs /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info method parameter /methodName/ +---------------- +|[source,tcl] +--------------- +/obj/ info default /methodName/ +----------------- +|[source,tcl] +---------------- +/obj/ info method parameter /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info pre /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info method precondition /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info pre /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info method precondition /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info post /methodName/ +---------------- +|[source,tcl] +---------------- +/obj/ info post /methodName/ +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info method definition /methodName/ +---------------- +|====================== + +For definition of class object specific methods, use modifier `class-object` as shown in examples above. + +==== List Filter or Mixins + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ info filter ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +# ... info filter methods -order ... returns method-handles +# instead of triples (applies to all three variants) + +/obj/ info filter methods ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info filterguard /name/ +---------------- +|[source,tcl] +---------------- +/obj/ info filter guard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info filter ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ class-object info filter methods ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info filterguard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ class-object info filter guard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info instfilter ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info filter methods ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info instfilterguard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info filter guard /name/ +---------------- +|[source,tcl] +---------------- +/obj/ info mixin ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info mixin classes ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/obj/ info mixinguard /name/ +---------------- +|[source,tcl] +---------------- +/obj/ info mixin guard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info mixin ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ class-object info mixin classes ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info mixinguard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ class-object info mixin guard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info instmixin ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info mixin classes ?-guards? ?-order? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info instmixinguard /name/ +---------------- +|[source,tcl] +---------------- +/cls/ info mixin guard /name/ +---------------- +|====================== + +==== List definition of methods defined by aliases, setters or forwarders + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info method definition /methodName/ +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +--------------- +/cls/ info method definition /methodName/ +---------------- +|====================== + + +==== List fully qualified name of method + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info method handle /methodName/ +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ ?class-object? info method handle /methodName/ +---------------- +|====================== + +==== List type of a method + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info method type /methodName/ +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/cls/ ?class-object? info method type /methodName/ +---------------- +|====================== + +==== List the scope of mixin classes + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/cls/ info mixinof ?-closure? ?pattern? +---------------- +|[source,tcl] +---------------- +# List objects, where /cls/ is a per-object mixin + +/cls/ info mixinof -scope object ?-closure? ?pattern? +---------------- +|[source,tcl] +---------------- +/cls/ info instmixinof ?-closure? ?pattern? +---------------- +|[source,tcl] +---------------- +# List classes, where /cls/ is a per-class mixin + +/cls/ info mixinof -scope class ?-closure? ?pattern? +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +# List objects and classes, where /cls/ is +# either a per-object or a per-class mixin + +/cls/ info mixinof -scope all ?-closure? ?pattern? +---------------- +[source,tcl] +---------------- +/cls/ info mixinof ?-closure? ?pattern? +---------------- +|====================== + +==== Check properties of object and classes + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ istype /sometype/ +---------------- +|[source,tcl] +---------------- +/obj/ info has type /sometype/ +---------------- +|[source,tcl] +---------------- +/obj/ ismixin /cls/ +---------------- +|[source,tcl] +---------------- +/obj/ info has mixin /cls/ +---------------- +|[source,tcl] +---------------- +/obj/ isclass ?/cls/? +---------------- +|[source,tcl] +---------------- +/obj/ info is class +---------------- +|[source,tcl] +---------------- +/obj/ ismetaclass /cls/ +---------------- +|[source,tcl] +---------------- +/obj/ info is metaclass +---------------- +|[source,tcl] +---------------- +# n.a. +---------------- +|[source,tcl] +---------------- +/obj/ info is baseclass +---------------- +|[source,tcl] +---------------- +/obj/ isobject /obj/ +---------------- +|[source,tcl] +---------------- +::nsf::isobject /obj/ +---------------- +|====================== + +==== Call-stack Introspection + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +self +---------------- +|[source,tcl] +---------------- +current +---------------- +[source,tcl] +---------------- +current object +---------------- +|[source,tcl] +---------------- +self class +---------------- +|[source,tcl] +---------------- +current class +---------------- +|[source,tcl] +---------------- +self proc +---------------- +|[source,tcl] +---------------- +current method +---------------- +|[source,tcl] +---------------- +self callingclass +---------------- +|[source,tcl] +---------------- +current currentclass +---------------- +|[source,tcl] +---------------- +self callingobject +---------------- +|[source,tcl] +---------------- +current callingobject +---------------- +|[source,tcl] +---------------- +self callingproc +---------------- +|[source,tcl] +---------------- +current callingmethod +---------------- +|[source,tcl] +---------------- +self calledclass +---------------- +|[source,tcl] +---------------- +current calledclass +---------------- +|[source,tcl] +---------------- +self calledproc +---------------- +|[source,tcl] +---------------- +current calledmethod +---------------- +|[source,tcl] +---------------- +self isnextcall +---------------- +|[source,tcl] +---------------- +current isnextcall +---------------- +|[source,tcl] +---------------- +self next +---------------- +|[source,tcl] +---------------- +# Returns method-handle +current next +---------------- +|[source,tcl] +---------------- +self filterreg +---------------- +|[source,tcl] +---------------- +# Returns method-handle +current filterreg +---------------- +|[source,tcl] +---------------- +self callinglevel +---------------- +|[source,tcl] +---------------- +current callinglevel +---------------- +|[source,tcl] +---------------- +self activelevel +---------------- +|[source,tcl] +---------------- +current activelevel +---------------- +|====================== + + +=== Other Predefined Methods + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ requireNamespace +---------------- +|[source,tcl] +---------------- +/obj/ require namespace +---------------- +|====================== + + +=== Dispatch, Aliases, etc. +todo: to be done or omitted + +=== Assertions + +[options="header",cols="asciidoc,asciidoc",frame="none",valign="middle"] +|====================== +|XOTcl |Next Scripting Language + +|[source,tcl] +---------------- +/obj/ check /checkoptions/ +---------------- +|[source,tcl] +---------------- +::nsf::assertion /obj/ check /checkptions/ +---------------- +|[source,tcl] +---------------- +/obj/ info check +---------------- +|[source,tcl] +---------------- +::nsf::assertion /obj/ check +---------------- +|[source,tcl] +---------------- +/obj/ invar /conditions/ +---------------- +|[source,tcl] +---------------- +::nsf::assertion /obj/ object-invar /conditions/ +---------------- +|[source,tcl] +---------------- +/obj/ info invar +---------------- +|[source,tcl] +---------------- +::nsf::assertion /obj/ object-invar +---------------- +|[source,tcl] +---------------- +/cls/ instinvar /conditions/ +---------------- +|[source,tcl] +---------------- +::nsf::assertion /cls/ class-invar /conditions/ +---------------- +|[source,tcl] +---------------- +/cls/ info instinvar +---------------- +|[source,tcl] +---------------- +::nsf::assertion /cls/ class-invar +---------------- +|[source,tcl] +---------------- +/cls/ invar /conditions/ +---------------- +|[source,tcl] +---------------- +::nsf::assertion /cls/ object-invar /conditions/ +---------------- +|[source,tcl] +---------------- +/cls/ info invar +---------------- +|[source,tcl] +---------------- +::nsf::assertion /cls/ object-invar +---------------- +|====================== + +=== Method Protection + +As described <>, NX supports method +protection via the method modifiers `protected` and `public`. A +protected method can be only called from an object of that class, +while public methods can be called from every object. The method +protection can be used to every kind of method, such as e.g. scripted +methods, aliases, forwarders, setters or attributes. For invocations, +the most specific definition (might be a mixin) is used for +determining the protection. + +== Incompatibilities between XOTcl 1 and XOTcl 2 + +=== Resolvers + +The resolvers (variable resolvers, function resolvers) of the Next +Scripting Framework are used as well within XOTcl 2. When variable +names or method names starting with a single colon are used in XOTcl 1 +scripts, conflicts will arise with the resolver. These names must be +replaced. + +=== Parameters + +The following changes for parameters could be regarded as bug-fixes. + +==== Parameter usage without a value + +In XOTcl 1, it was possible to call a parameter method during object +creation via the -param without a value (in the example below `-x`. + +[source,tcl] +---------------- +Class Foo -parameter {x y} +Foo f1 -x -y 1 +---------------- + +Such cases are most likely mistakes. All parameter configurations in XOTcl 2 require an argument. + +==== Ignored Parameter definitions + +In XOTcl 1, a more specific parameter definition without a default was ignored +when a more general parameter definition with a default was +present. In the example below, the object `b1` contained in XOTcl 1 +incorrectly the parameter `x` (set via default from `Foo`), while in +XOTcl 2, the variable won't be set. +[source,tcl] +---------------- +Class Foo -parameter {{x 1}} +Class Bar -superclass Foo -parameter x +Bar b1 +---------------- + + +=== Calling objects via method interface + +Since the Next Scripting Framework supports the so-called ensemble +objects, which ease the definition of sub-methods substantially, +objects registered as methods have different semantics. In XOTcl 1, it +was possible to call e.g. a method foo of the slot object +`Foo::slot::ints` via the following two interfaces the same way: + +[source,tcl] +---------------- +Foo::slot::ints foo ... +Foo slot ints foo ... +---------------- + +In the Next Scripting Framework, only the first form has the same +semantic as before. In the second form (invocation of objects via +method interface) has now the ensemble object semantics. This means +that in the second case the current object of method foo is now Foo +instead of ints. + +=== Slots + +All slot objects (also XOTcl slot objects) are now next-scripting +objects of baseclass `::nx::Slot`. The name of the experimental +default-setter `initcmd` was changed to `defaultcmd`. Code directly +working on the slots objects has to be adapted. + +=== Obsolete commands + +Parameter-classes were rarely used and have been replaced by the more +general object parameterization. Therefore, `cl info parameterclass` has +been removed. + +=== Stronger Checking + +The Next Scripting Framework performs stronger checking than XOTcl 1 +For example, the requiredness of slots in XOTcl 1 was just a +comment, while XOTcl 2 enforces it. + +=== Exit Handlers + +The exit hander interface changed from a method of `::xotcl::Object` +into the Tcl command `::nsf::exithandler`: + +[source,tcl] +---------------- +::nsf::exithandler set|get|unset ?arg? +---------------- + +