Index: doc/next-migration.html =================================================================== diff -u -rda6586782390b02ed7660b56417c3db00d63d1c3 -r72ea1813ed0addc436756c0ee1c6b88643a4400c --- doc/next-migration.html (.../next-migration.html) (revision da6586782390b02ed7660b56417c3db00d63d1c3) +++ doc/next-migration.html (.../next-migration.html) (revision 72ea1813ed0addc436756c0ee1c6b88643a4400c) @@ -585,87 +585,205 @@

We expect that many user will find it attractive to upgrade from XOTcl 1 to XOTcl 2, and some other users will upgrade to NX. This document focuses mainly on the differences between XOTcl 1 and -NX, but addresses as well potential incompatibilitied between XOTcl 1 +NX, but addresses as well potential incompatibilities between XOTcl 1 and XOTcl 2. For an introduction to NX, please consult the NX tutorial.

1. Differences Between XOTcl and NX

-

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

-
    +

    The Next Scripting Framework supports Language Oriented Programming +by providing means to define potentially multiple object systems with +different naming and functionality in a single interpreter. This +makes the Next Scripting Framework a powerful instrument for defining +multiple languages such as e.g. domain specific languages. This focus +differs from XOTcl 1.

    +

    Technically, the language framework approach means that the languages +implemented by the Next Scripting Framework (most prominently XOTcl 2 +and NX) are typically fully scripted and can be loaded via the usual +Tcl package require mechanism.

    +

    Some of the new features below are provided by the Next Scripting +Framework, some are implemented via the script files for XOTcl 2 and +NX.

    +
    +

    1.1. Features of NX

    +

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

    +
    1. -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 resolversm which make some methods necessary in XOTcl - obsolete in NX (especially for importing instance variables). On the - other hand, XOTcl is complete symmetrical in this respect. +Stronger Encapsulation: 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, which make some + methods necessary in XOTcl 1 obsolete in NX (especially for importing + instance variables). The encapsulation of NX is stronger than in + XOTcl but still weak compared to languages like C++; a developer can + still access other objects' variables via some idioms, but NX makes + accesses to other objects variables explicit. The requiredness to + make these accesses explicit should encourage developer to implement + well defined interfaces to provide access to instance variables.

    2. -The encapsulation of NX is stronger than in XOTcl but still weak - compared to languages like C++; a developer can still access other - objects' variables via some idioms, but NX makes accesses to other - objects variables explicit. The requiredness to make these - accesses explicit should encourage developer to implement well - defined interfaces to provide access to instance variables. +Additional Forms of Method Definition and Reuse: + The Next Scripting Language + provides much more orthogonal means to define, reuse and + introspect scripted and C-implemented methods.

      +
        +
      1. +

        +It is possible to use NX alias to register methods + under arbitrary names for arbitrary objects or classes. +

      2. -The Next Scripting Language provides means of method - protection. Therefore developers have to define interfaces in - order to use methods from other objects. +NX provides means for method protection (method modifiers + public and protected). Therefore developers have to define + explicitly public interfaces in order to use methods from other + objects.

      3. -The Next Scripting Language provides scripted init blocks for - objects and classes (replacement for the dangerous dash "-" - mechanism in XOTcl that allows to set variables and invoke methods - upon object creation). +One can invoke in NX fully qualified methods to invoke + methods outside the precedence path.

      4. -The Next Scripting Language provides much more orthogonal means to - define, reuse and introspect scripted and C-implemented methods. +One can define in NX ensemble methods (similar to + commands and subcommands) in a convenient way to provide + extensible, hierarchical naming of methods.

      5. -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). +One can use in NX the same interface to query (introspect) + C-implemented and scripted methods/commands.

      6. +
      +
    3. -The naming of the methods in the Next Scripting Language is much more - in line with the mainstream naming conventions in OO languages. +Orthogonal Parameterization: + The Next Scripting Language provides an orthogonal framework for + parametrization of methods and objects.

      +
        +
      1. +

        +In NX, the same argument parser is used for +

        +
          +
        • +

          +Scripted Methods +

        • -The Next Scripting Language has a much smaller interface (less - predefined methods) than XOTcl (see Table 1), allthough the - expressability was increased in NX. +C-implemented methods and Tcl commands

        • +
        • +

          +Object Parametrization +

          +
        +
      2. +
      3. +

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

        +
      4. +
      5. +

        +While XOTcl 1 supported only non-positional arguments at the + begin of the argument list, these can be used now at arbitrary + positions. +

        +
      6. +
      +
    4. +
    5. +

      +Value Checking: +

      +
        +
      1. +

        +The Next Scripting Language supports checking of the input + parmeters and the return values of scripted and C-implemented + methods and commands. +

        +
      2. +
      3. +

        +NX provides a set of predefined checkers (like e.g. integer, + boolean, object, …) which can be extended by the + applications. +

        +
      4. +
      5. +

        +Value Checking can be used for single and multi-valued + parameters. One can e.g. define a list of integers + with at least one entry by the parameter specification + integer,1..n. +

        +
      6. +
      7. +

        +Value Checking can be turned on/off globally or on the + method/command level. +

        +
      8. +
      +
    6. +
    7. +

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

      +
    8. +
    9. +

      +More Conventional Naming for Predefined Methods: The naming of + the methods in the Next Scripting Language is much more in line with + the mainstream naming conventions in OO languages. While for example + XOTcl uses proc and instproc for object specific and inheritable + methods, NX uses simply method. +

      +
    10. +
    11. +

      +Much smaller Interface: The Next Scripting Language has a much + smaller interface (i.e. provides less predefined methods) than + XOTcl (see Table 1), although the expressability was increased in + NX. +

      +
    12. +
    - +@@ -707,16 +825,24 @@
    Table 1. Comparison of the Number of Methods in NX and XOTclTable 1. Comparison of the Number of Predefined Methods in NX and XOTcl
    +

    This comparison list compares mostly XOTcl 1 with NX, some features +are also available in XOTcl 2 (2a, 2c 2d, 3, 4).

    +
    +
    +

    1.2. NX and XOTcl Scripts

    Below is a small, introductory example showing an implementation of a -class Stack in NX and XOTcl. NX supports a block syntax, where the -methods are defined during the creation of the class. The XOTcl syntax -is slightly more redundant, since every definition of a method is a -single toplevel command starting with the class name (also NX supports -the style used in XOTcl). In NX, all methods are per default -protected (XOTcl does not support protection). In NX methods are -defined in the definition of the class via :method or :public -method. In XOTcl methods are defined via the instproc method.

    -

    Another difference is the notation to refere to instance variables. In +class Stack in NX and XOTcl. The purpose of this first example is +just a quick overview. We will go into much more detailed comparison +in the next sections.

    +

    NX supports a block syntax, where the methods are defined during the +creation of the class. The XOTcl syntax is slightly more redundant, +since every definition of a method is a single toplevel command +starting with the class name (also NX supports the style used in +XOTcl). In NX, all methods are per default protected (XOTcl does not +support protection). In NX methods are defined in the definition of +the class via :method or :public method. In XOTcl methods are +defined via the instproc method.

    +

    Another difference is the notation to refer to instance variables. In NX, instance variable are named with a single colon in the front. In XOTcl, instance variables are imported using instvar.

    @@ -804,10 +930,8 @@
    -
-
-

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

-
+
+

1.3. 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 @@ -874,14 +998,15 @@ Class) of XOTcl or NX into the current namespace.

+
-

3. XOTcl Idioms in the Next Scripting Language

+

2. XOTcl Idioms in the Next Scripting Language

The following sections are intended for reader familiar with XOTcl and show, how certain language Idioms of XOTcl can be expressed in NX. In some cases, multiple possible realizations are listed

-

3.1. Defining Objects and Classes

+

2.1. Defining Objects and Classes

When creating objects or classes, one should use the method create explicitly. In XOTcl, a default unknown handler was provided for classes, which create for every unknown method invocation an @@ -961,7 +1086,7 @@

-

3.2. Defining Methods

+

2.2. Defining Methods

In general, both XOTcl and NX support methods on the object level (per-object methods, i.e. methods only applicable to a single object) and on the class level (methods inherited to instances of the @@ -984,7 +1109,7 @@ (section 3.2.1) and C-defined methods (section 3.2.2). Section 3.2.3 introduces method protection, which is only supported by NX.

-

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

+

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

The following examples show the definition of a class and its methods in the init-block of a class (NX only), and the definition of methods via separate top level calls (XOTcl and NX).

@@ -1118,7 +1243,7 @@
-

3.2.2. Different Kinds of Methods

+

2.2.2. Different Kinds of Methods

This section describes various kinds of methods. The different kinds of methods are defined via different method-defining methods, which are summarized in the following table for XOTcl and NX.

@@ -1354,7 +1479,7 @@
-

3.2.3. Method Modifiers and Method Protection

+

2.2.3. Method Modifiers and Method Protection

NX supports the three method modifiers class, public and protected. All method modifiers can be written in front of every method defining command. The method modifier class is used to denote @@ -1438,7 +1563,7 @@

-

3.3. Resolvers

+

2.3. Resolvers

The Next Scripting Framework defines Tcl resolvers for method and variable names to implement object specific behavior. Within the bodies of scripted methods these resolver treat variable and function @@ -1449,7 +1574,7 @@

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

-

3.3.1. Invoking Methods

+

2.3.1. Invoking Methods

In XOTcl, a method of the same object can be invoked via my, or in general via using the name of the object in front of the method name.

In NX, the own methods are called via the method name prefixed with a @@ -1516,7 +1641,7 @@

-

3.3.2. Accessing Own Instance Variables from Method Bodies

+

2.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. This means that in NX it is syntactically easier to access @@ -1773,7 +1898,7 @@

-

3.3.3. Accessing Instance Variables of other Objects

+

2.3.3. Accessing Instance Variables of other Objects

-

3.4. Parameters

+

2.4. Parameters

While XOTcl 1 had very limited forms of parameters, XOTcl 2 and NX provide a generalized and highly orthogonal parameter handling with various kinds of value constraints (also called value checker). We @@ -1954,7 +2079,7 @@

based on the same mechanisms.

-

3.4.1. Object Parameters

+

2.4.1. Object Parameters

Object parameters are supported in XOTcl via the method parameter. Since the term "parameter" is underspecified, NX uses the term "attribute". To define multiple attributes in a short form, NX @@ -2439,7 +2564,7 @@

-

3.4.2. Method Parameters

+

2.4.2. Method Parameters

The method parameters specifications in XOTcl 1 were limited and allowed only value constraints for non positional arguments.

NX and XOTcl 2 provide value constraints for all kind of method parameters. @@ -2573,7 +2698,7 @@

-

3.4.3. Return Value Checking

+

2.4.3. Return Value Checking

Return value checking is a functionality that was not yet available in XOTcl 1. A return value checker assures that a method returns always a value satisfying some value constraints. Return value checkers can be defined on @@ -2652,7 +2777,7 @@

-

3.5. Interceptors

+

2.5. Interceptors

XOTcl and NX allow the definition of the same set of interceptors, namely class- and object-level mixins and class- and object-level filters. The primary difference in NX is the naming, since NX @@ -2663,7 +2788,7 @@ If a mixin is registered on the class object, one has to use the modifier class (in the same way as e.g. for defining methods).

-

3.5.1. Register Mixin Classes and Mixin Guards

+

2.5.1. Register Mixin Classes and Mixin Guards

-

3.5.2. Register Filters and Filter Guards

+

2.5.2. Register Filters and Filter Guards

-

3.6. Introspection

+

2.6. Introspection

In general, introspection in NX became more orthogonal and less dependent on the type of the method. In XOTcl it was e.g. necessary that a developer had to know, whether a method is e.g. scripted or not @@ -2904,7 +3029,7 @@ parametersyntax. In addition, NX provides means to query the type of a method, and NX allows to filter by the type of the method.

-

3.6.1. List methods defined by classes

+

2.6.1. List methods defined by classes

While XOTcl uses different names for obtaining different kinds of methods defined by a class, NX uses info methods in an orthogonal manner. NX allows as well to use the call protection to filter the @@ -3110,7 +3235,7 @@

-

3.6.2. List methods defined by objects

+

2.6.2. List methods defined by objects

While XOTcl uses different names for obtaining different kinds of methods defined by an object, NX uses info methods in an orthogonal manner. NX allows as well to use the call protection to filter the @@ -3316,7 +3441,7 @@

-

3.6.3. List class object specific methods

+

2.6.3. List class object specific methods

When class specific properties are queried, NX required to use the modifier class (like for the definition of the methods). In all other respects, this section is identical to the previous one.

@@ -3522,7 +3647,7 @@
-

3.6.4. Check existence of a method

+

2.6.4. Check existence of a method

NX provides multiple ways of checking, whether a method exists; one can use info method exists to check, if a given method exists (return boolean), or one can use info methods ?pattern?, where @@ -3603,7 +3728,7 @@

-

3.6.5. List callable methods

+

2.6.5. List callable methods

In order to obtain for an object the set of artefacts defined in the class hierarchy, NX uses info lookup. One can either lookup methods (via info lookup methods) or slots (via info lookup slots). The @@ -3745,7 +3870,7 @@

-

3.6.6. List object/class where some method is defined

+

2.6.6. List object/class where some method is defined

info lookup can be used as well to determine, where exactly an artefact is located. One can obtain this way a method handle, where a method or filter is defined.

@@ -3825,7 +3950,7 @@
-

3.6.7. List definition of scripted methods defined by classes

+

2.6.7. List definition of scripted methods defined by classes

XOTcl contains a long list of info subcommands for different kinds of methods and for obtaining more detailed information about these methods.

@@ -4065,7 +4190,7 @@
-

3.6.8. List definition of scripted object specific methods

+

2.6.8. List definition of scripted object specific methods

While XOTcl uses different names for info options for objects and classes (using the prefix "inst"), the names in NX are the same.

@@ -4297,7 +4422,7 @@ class as shown in examples above.

-

3.6.9. List Filter or Mixins

+

2.6.9. List Filter or Mixins

In NX all introspection options for filters are grouped under info filter and all introspection options for mixins are under info mixin. Therefore, NX follows here the approach of using hierarchical @@ -4645,7 +4770,7 @@

-

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

+

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

As mentioned earlier, info method definition can be used on every kind of method.

@@ -4719,7 +4844,7 @@
-

3.6.11. List Method-Handles

+

2.6.11. List Method-Handles

NX supports method-handles to provide means to obtain further information about a method or to change maybe some properties of a method. When a method is created, the method creating method returns @@ -4795,7 +4920,7 @@

-

3.6.12. List type of a method

+

2.6.12. List type of a method

The method info method type is new in NX to obtain the type of the specified method.

@@ -4869,7 +4994,7 @@
-

3.6.13. List the scope of mixin classes

+

2.6.13. List the scope of mixin classes

NX provides a richer set of introspection options to obtain information, where mixins classes are mixed into.

@@ -4989,7 +5114,7 @@
-

3.6.14. Check properties of object and classes

+

2.6.14. Check properties of object and classes

Similar as noted before, NX uses rather a hierarchical approach of naming using multiple layers of subcommands).

@@ -5167,7 +5292,7 @@
-

3.6.15. Call-stack Introspection

+

2.6.15. Call-stack Introspection

Call-stack introspection is very similar in NX and XOTcl. NX uses for subcommand the term current instead of self, since self has a strong connotation to the current object. The term proc is renamed @@ -5544,7 +5669,7 @@

-

3.7. Other Predefined Methods

+

2.7. Other Predefined Methods

-

3.8. Dispatch, Aliases, etc.

+

2.8. Dispatch, Aliases, etc.

todo: to be done or omitted

-

3.9. Assertions

+

2.9. Assertions

In contrary to XOTcl, NX provides no pre-registered methods for assertion handling. All assertion handling can e performed via the Next Scripting primitive nsf::method::assertion.

@@ -5851,7 +5976,7 @@
-

3.10. Method Protection

+

2.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, @@ -5864,21 +5989,21 @@

-

4. Incompatibilities between XOTcl 1 and XOTcl 2

+

3. Incompatibilities between XOTcl 1 and XOTcl 2

-

4.1. Resolvers

+

3.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

+

3.2. Parameters

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

-

4.2.1. Parameter usage without a value

+

3.2.1. Parameter usage without a value

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

@@ -5899,7 +6024,7 @@

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

-

4.2.2. Ignored Parameter definitions

+

3.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 @@ -5923,7 +6048,7 @@ Bar b1

-

4.2.3. Changing classes and superclasses

+

3.2.3. Changing classes and superclasses

NX does not define the methods class and superclass but allows to alter the class/superclass via configure. The class and superclass can be certainly queried in all variants with info class or info superclass.

@@ -5950,7 +6075,7 @@
-

4.3. Calling Objects via Method Interface

+

3.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 @@ -5978,26 +6103,26 @@ instead of ints.

-

4.4. Slots

+

3.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

+

3.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

+

3.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

+

3.7. Exit Handlers

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

@@ -6021,7 +6146,7 @@ Index: doc/next-migration.txt =================================================================== diff -u -rda6586782390b02ed7660b56417c3db00d63d1c3 -r72ea1813ed0addc436756c0ee1c6b88643a4400c --- doc/next-migration.txt (.../next-migration.txt) (revision da6586782390b02ed7660b56417c3db00d63d1c3) +++ doc/next-migration.txt (.../next-migration.txt) (revision 72ea1813ed0addc436756c0ee1c6b88643a4400c) @@ -52,56 +52,121 @@ We expect that many user will find it attractive to upgrade from XOTcl 1 to XOTcl 2, and some other users will upgrade to NX. This document focuses mainly on the differences between XOTcl 1 and -NX, but addresses as well potential incompatibilitied between XOTcl 1 +NX, but addresses as well potential incompatibilities between XOTcl 1 and XOTcl 2. For an introduction to NX, please consult the NX tutorial. Differences Between XOTcl and NX ------------------------------- -In general, the Next Scripting Language (NX) differs from XOTcl in -the following respects: +The Next Scripting Framework supports _Language Oriented Programming_ +by providing means to define potentially multiple object systems with +different naming and functionality in a single interpreter. This +makes the Next Scripting Framework a powerful instrument for defining +multiple languages such as e.g. domain specific languages. This focus +differs from XOTcl 1. -- 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 resolversm which make some methods necessary in XOTcl - obsolete in NX (especially for importing instance variables). On the - other hand, XOTcl is complete symmetrical in this respect. +Technically, the language framework approach means that the languages +implemented by the Next Scripting Framework (most prominently XOTcl 2 +and NX) are typically fully scripted and can be loaded via the usual +Tcl +package require+ mechanism. -- The encapsulation of NX is stronger than in XOTcl but still weak - compared to languages like C++; a developer can still access other - objects' variables via some idioms, but NX _makes accesses to other - objects variables explicit_. The requiredness to make these - accesses explicit should encourage developer to implement well - defined interfaces to provide access to instance variables. +Some of the new features below are provided by the Next Scripting +Framework, some are implemented via the script files for XOTcl 2 and +NX. -- The Next Scripting Language provides means of _method - protection_. Therefore developers have to define interfaces in - order to use methods from other objects. +=== Features of NX -- The Next Scripting Language provides _scripted init blocks_ for - objects and classes (replacement for the dangerous dash "-" - mechanism in XOTcl that allows to set variables and invoke methods - upon object creation). +In general, the Next Scripting Language (NX) differs from XOTcl +in the following respects: -- The Next Scripting Language provides much more orthogonal means to - _define, reuse and introspect scripted and C-implemented methods_. +. *Stronger Encapsulation:* 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_, which make some + methods necessary in XOTcl 1 obsolete in NX (especially for importing + instance variables). The encapsulation of NX is stronger than in + XOTcl but still weak compared to languages like C++; a developer can + still access other objects' variables via some idioms, but NX _makes + accesses to other objects variables explicit_. The requiredness to + make these accesses explicit should encourage developer to implement + well defined interfaces to provide access to instance variables. -- 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). +. *Additional Forms of Method Definition and Reuse:* + The Next Scripting Language + provides much more orthogonal means to _define, reuse and + introspect_ scripted and C-implemented methods. -- The naming of the methods in the Next Scripting Language is much more - in line with the mainstream naming conventions in OO languages. + .. It is possible to use NX +alias+ to register methods + under arbitrary names for arbitrary objects or classes. -- The Next Scripting Language has a much _smaller interface_ (less - predefined methods) than XOTcl (see Table 1), allthough the - expressability was increased in NX. + .. NX provides means for _method protection_ (method modifiers + +public+ and +protected+). Therefore developers have to define + explicitly public interfaces in order to use methods from other + objects. -.Comparison of the Number of Methods in NX and XOTcl + .. One can invoke in NX fully qualified methods to invoke + methods outside the precedence path. + + .. One can define in NX _ensemble methods_ (similar to + commands and subcommands) in a convenient way to provide + extensible, hierarchical naming of methods. + + .. One can use in NX the same interface to query (introspect) + C-implemented and scripted methods/commands. + +. *Orthogonal Parameterization:* + The Next Scripting Language provides an _orthogonal framework for + parametrization_ of methods and objects. + .. In NX, the same argument parser is used for + * Scripted Methods + * C-implemented methods and Tcl commands + * Object Parametrization + .. While XOTcl 1 provided only value-checkers for non-positional + arguments for methods, the Next Scripting Framework provides + the same value checkers for positional and non-positional + arguments of methods, as well as for positional and + non-positional object parameters (`-parameter` in + XOTcl 1). + .. While XOTcl 1 supported only non-positional arguments at the + begin of the argument list, these can be used now at arbitrary + positions. + +. *Value Checking:* + + .. The Next Scripting Language supports checking of the _input + parmeters_ and the _return values_ of scripted and C-implemented + methods and commands. + + .. NX provides a set of predefined checkers (like e.g. +integer+, + +boolean+, +object+, ...) which can be extended by the + applications. + + .. Value Checking can be used for _single_ and _multi-valued_ + parameters. One can e.g. define a list of integers + with at least one entry by the parameter specification + +integer,1..n+. + + .. Value Checking can be turned on/off globally or on the + method/command level. + +. *Scripted Init Blocks:* The Next Scripting Language provides + _scripted init blocks_ for objects and classes (replacement for the + dangerous dash "-" mechanism in XOTcl that allows to set variables + and invoke methods upon object creation). + +. *More Conventional Naming for Predefined Methods:* The naming of + the methods in the Next Scripting Language is much more in line with + the mainstream naming conventions in OO languages. While for example + XOTcl uses +proc+ and +instproc+ for object specific and inheritable + methods, NX uses simply +method+. + +. *Much smaller Interface:* The Next Scripting Language has a much + _smaller interface_ (i.e. provides less predefined methods) than + XOTcl (see Table 1), although the expressability was increased in + NX. + +.Comparison of the Number of Predefined Methods in NX and XOTcl [width="50%",frame="topbot",options="header,footer",cols="3,>1,>1"] |====================== ||NX|XOTcl @@ -112,18 +177,26 @@ |Total | 41|125 |====================== +This comparison list compares mostly XOTcl 1 with NX, some features +are also available in XOTcl 2 (2a, 2c 2d, 3, 4). +=== NX and XOTcl Scripts + Below is a small, introductory example showing an implementation of a -class +Stack+ in NX and XOTcl. NX supports a block syntax, where the -methods are defined during the creation of the class. The XOTcl syntax -is slightly more redundant, since every definition of a method is a -single toplevel command starting with the class name (also NX supports -the style used in XOTcl). In NX, all methods are per default -protected (XOTcl does not support protection). In NX methods are -defined in the definition of the class via +:method+ or +:public -method+. In XOTcl methods are defined via the +instproc+ method. +class +Stack+ in NX and XOTcl. The purpose of this first example is +just a quick overview. We will go into much more detailed comparison +in the next sections. -Another difference is the notation to refere to instance variables. In +NX supports a block syntax, where the methods are defined during the +creation of the class. The XOTcl syntax is slightly more redundant, +since every definition of a method is a single toplevel command +starting with the class name (also NX supports the style used in +XOTcl). In NX, all methods are per default protected (XOTcl does not +support protection). In NX methods are defined in the definition of +the class via +:method+ or +:public method+. In XOTcl methods are +defined via the +instproc+ method. + +Another difference is the notation to refer to instance variables. In NX, instance variable are named with a single colon in the front. In XOTcl, instance variables are imported using +instvar+. @@ -181,9 +254,9 @@ -------------------------------------------------- |====================== -Using XOTcl 2.0 and the Next Scripting Language in a Single Interpreter ---------------------------------------------------------------------- +=== 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