Here comes general text, maybe partly from slides/paper …. TODO: Maybe we -should not refer to ::nsf here, just to ::nx …
Index: doc/next-migration.html =================================================================== diff -u -r268f85047af3501fc9e1b7798b9f3ec51cac77f7 -r3df933477f01d26d32220be5a1c87bfc0c5b7685 --- doc/next-migration.html (.../next-migration.html) (revision 268f85047af3501fc9e1b7798b9f3ec51cac77f7) +++ doc/next-migration.html (.../next-migration.html) (revision 3df933477f01d26d32220be5a1c87bfc0c5b7685) @@ -553,12 +553,33 @@ migration guide from XOTcl 1 to NX, and presents potential incompatibilities beween XOTcl 1.and XOTcl 2
- +The Next Scripting Language (NX) is a successor of XOTcl 1 and is +based on 10 years of experience with XOTcl in projects containing +several hundert thousand lines of code. The overall goal is to +improve the maintainability and stability of large projects, where +many developers are involved.
The Next Scripting Language is based on the Next Scripting Framework +which was developed based on the notion of language oriented +programming. The Next Scripting Frameworks provides C-level support +for defining and hosting multiple object systems in a single Tcl +interpreter. The whole definition of NX is fully scripted +(e.g. defined in nx.tcl). The Next Scripting Framework is shipped +with three language definitions, containing NX and XOTcl 2. Most of +the existing XOTcl 1 programs can be used without modification in the +Next Scripting Framework. The Next Scripting Framework requires Tcl +8.5 or newer.
Although NX is fully scripted (as well as XOTcl 2), our benchmarks +show that scripts based on NX are often 2 or 4 times faster than the +counterparts in XOTcl 1. But speed was not the primary focus on the +Next Scripting Environment: The goal was primarily to find ways to +repackage the power of XOTcl in an easy to learn environment, highly +orthogonal environment, which is better suited for large projects, +trying to reduce maintenance costs.
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 +and XOTcl 2. For an introduction to NX, please consult the NX tutorial.
-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 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.
-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 +The encapsulation of Next Scripting is stronger than in XOTcl but + 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 means of method + protection. Therefore developers have to define interfaces in order + to use methods from other objects.
The Next Scripting Language provides scripted init blocks for - objects and classes (replacement for the somewhat dangerous dash "-" + objects and classes (replacement for the dangerous dash "-" mechanism in XOTcl that allows to set variables and invoke methods upon object creation).
@@ -727,6 +750,12 @@+The naming of the methods in the The Next Scripting Language is much more + in line with the mainstream naming conventions in OO languages. +
+Below is a small, introductory example showing an implementation of a class Stack in NX and XOTcl. NX supports a block syntax, where the @@ -1843,15 +1872,35 @@
While XOTcl 1 had very limited forms of parameters, XOTcl 2 and nx +
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. We devide the parameters into -Object Parameters (parameters used for initializing objects and -classes) and Method Parameters (parameters passed to -methods). Furthermore, XOTcl 2 and NX support return value checker -based on the same mechanisms.
Furthermore, the Next Scripting Framework provides
+unified parameter checking (for object and method parameters) and +
++return value checking +
+based on the same mechanisms.
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 +provides the method attributes.
In XOTcl the method parameter is a shortcut for creating multiple +slot objects. Slot objects can be as well created in XOTcl directly +via the method slots to provide a much richer set of +meta-data for every attribute.
To make the definition of attributes more orthogonal, NX uses the +method attribute which can be used as well on the class and on the +object level. When an attribute is created, NX does actually three +things:
+Create a slot object, which can be specified in more detail + using the init-block of the slot object +
++Create an object parameter definition for the initialization of the + object (usable via a non-positional parameter during object + creation), and +
++register an accessor function (setter), for wich the usual + protection levels (public or protected) can be used. +
+XOTcl | +Next Scripting Language | +
---|---|
- # Parameters only available at class level
+ |
+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
+
- # Define object attributes -# (parameters for initializing objects) +# Object parameter specified via attribute methods +# (allow method modifiers and scripted configuration) -Class create C { - :attribute x - :attribute {y 1} - :class-object attribute oa1 +Class create Foo { + :attribute a + :attribute {b 1} } -Object create o { - :attribute oa2 -}
-
- Class create C \ - -attributes { - x - {y 1} -} |
+# Create instance of the class Foo
+Foo create f1 -a 0
+
+# Object f1 has a == 0 and b == 1
@@ -1967,18 +2053,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- # Object parameter specified via slots - -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 - |
+
- # Object parameter specified via attribute methods -# (allow method modifieres and scripted configuration) +# Define object parameter at the class +# and object level -Class create Foo { - :attribute a - :attribute {b 1} +Class create C { + :attribute x + :attribute {y 1} + :class-object attribute oa1 } -# Create instance of the class Foo -Foo create f1 -a 0 - -# Object f1 has a == 0 and b == 1 |
+Object create o {
+ :attribute oa2
+}
@@ -2034,8 +2109,8 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- # Object parameter with scripted definition, defining an attribute -# specific type checker +# Object parameter with scripted definition (init-block), +# defining an attribute specific type checker Class create Person { :attribute sex { @@ -2050,7 +2125,33 @@ } } |
XOTcl 1 did not support value constraints for object parameters (just +for non-positional arguments).
NX supports value constraints (value-checkers) for object and method +parameters in an orthogonal manner. NX provides a predefined set of +value checkers, which can be extended by the application developer.
In NX, the value checking is optional. This means that it is possible to +develop e.g. which a large amount of value-checking and deploy the +script with value checking turned off, if the script is highly +performance sensitive.
XOTcl | +Next Scripting Language | +
---|---|
- # 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 +# digit, double, false, graph, integer, lower, parameter, +# print, punct, space, true, upper, wordchar, xdigit # # User defined value constraints are possible. # All parameter value checkers can be turned on and off. # # Define a boolean attribute and an integer attribute with a -# default +# default firstly via "attributes", then with multiple +# "attribute" statements. Class create Foo -attributes { a:boolean @@ -2099,7 +2201,30 @@ :attribute {b:integer 1} } |
In XOTcl all object parameters were optional. Required parameters have +to be passed to the constructor of the object.
NX allows to define optional and required object +attributes. Therefore, object parameters can be used as the single +mechanism to parameterize objects. The constructors do not require any +parameters.
XOTcl | +Next Scripting Language | +|
---|---|---|
Class create Foo { :attribute {ints:integer,0..n ""} - :attribute objs:object,1..n - :attribute obj:object,0..1 + :attribute objs:object,1..n + :attribute obj:object,0..1 } |
- /obj/ info methods ?pattern? |
+|
@@ -2609,7 +2778,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info parametercmd ?pattern? |
+
- /obj/ info methods -methodtype setter ?pattern? |
+
@@ -2631,7 +2800,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info procs ?pattern? |
+
- /obj/ info methods -methodtype scripted ?pattern? |
+
@@ -2663,7 +2832,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info methods -methodtype alias ?pattern? |
+|
@@ -2685,7 +2854,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info methods -methodtype forwarder ?pattern? |
+|
@@ -2707,7 +2876,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info methods -methodtype object ?pattern? |
+|
@@ -2729,14 +2898,18 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info methods -callprotection public|protected ... |
+
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 +returned methods.
- /cls/ info methods ?pattern? |
+|
@@ -2783,7 +2956,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info instparametercmd ?pattern? |
+
- /cls/ info methods -methodtype setter ?pattern? |
+
@@ -2805,7 +2978,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info instprocs ?pattern? |
+
- /cls/ info methods -methodtype scripted ?pattern? |
+
@@ -2837,7 +3010,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info methods -methodtype alias ?pattern? |
+|
@@ -2859,7 +3032,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info methods -methodtype forwarder ?pattern? |
+|
@@ -2881,7 +3054,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info methods -methodtype object ?pattern? |
+|
@@ -2903,14 +3076,17 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info methods -callprotection public|protected ... |
+
When class-object specific properties are queried, NX required to use +the modifier class-object (like for the definition of the methods). +In all other respects, this section is identical to the previous one.
+
+ /cls/ info method definition /methodName/ |
+
+|
+ /cls/ info instbody /methodName/ |
- /cls/ info instdefault /methodName/ |
+
@@ -3439,14 +3659,16 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /cls/ info method definition /methodName/ |
+
While XOTcl uses different names for info options for objects and +classes (using the prefix "inst"), the names in NX are the same.
- /obj/ info method body /methodName/ |
+||
@@ -3493,7 +3715,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info args /methodName/ |
+
- /obj/ info method args /methodName/ |
+|
@@ -3515,7 +3737,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info nonposargs /methodName/ |
+
- /obj/ info method parameter /methodName/ |
+|
@@ -3537,7 +3759,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info default /methodName/ |
+
- /obj/ info pre /methodName/ |
+
- /obj/ info method precondition /methodName/ |
+
@@ -3613,7 +3835,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info post /methodName/ |
+||
@@ -3635,15 +3857,20 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- /obj/ info method definition /methodName/ |
+
For definition of class object specific methods, use modifier class-object as shown in examples above.
For definition of class object specific methods, use the modifier +class-object as shown in examples above.
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 +subcommands rather than using a flat namespace.
@@ -4444,7 +4687,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current class |
+
@@ -4466,7 +4709,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current method |
+
@@ -4488,7 +4731,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current currentclass |
+
@@ -4510,7 +4753,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current callingobject |
+
@@ -4532,7 +4775,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current callingmethod |
+
@@ -4554,7 +4797,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current calledclass |
+
@@ -4576,7 +4819,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current calledmethod |
+
@@ -4598,7 +4841,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current isnextcall |
+
@@ -4621,7 +4864,7 @@
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
# Returns method-handle -current next |
+current next
@@ -4644,7 +4887,7 @@
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
# Returns method-handle
-current filterreg |
+current filterreg
@@ -4666,7 +4909,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current callinglevel |
+
@@ -4688,7 +4931,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- current activelevel |
+
/obj/ require namespace
# n.a.
/obj/ require method
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::assertion.