Index: doc/next-migration.html
===================================================================
diff -u -r417e9e54ae7b0af1ee69c34525ad99c2beabedf8 -r74bae7e8ef9109fbcd95b77be8cf422ce330b59d
--- doc/next-migration.html (.../next-migration.html) (revision 417e9e54ae7b0af1ee69c34525ad99c2beabedf8)
+++ doc/next-migration.html (.../next-migration.html) (revision 74bae7e8ef9109fbcd95b77be8cf422ce330b59d)
@@ -734,8 +734,8 @@
Migration Guide for the Next Scripting Language
Gustaf Neumann
<neumann@wu-wien.ac.at>
-version 2.1,
-March 2011
+version 2.2,
+May 2013
Table of Contents
@@ -905,7 +905,7 @@
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
+ non-positional configure parameters (
-parameter
in
XOTcl 1).
@@ -1523,10 +1523,9 @@
@@ -1538,9 +1537,10 @@
to variables (called parametercmd
and instparametercmd
). The
accessor functions are used normally internally when object-specific
parameters are defined (see Section 3.4).
-In NX forwarders are called forward
. NX does not provide an own
-method to define variable accessors, but uses the Next Scripting
-Framework primitive nsf::method::setter
for it.
+In NX forwarders are called forward
. NX does not provide an public
+available method to define variable accessors like parametercmd
in
+XOTcl, but use interanlly the Next Scripting Framework primitive
+nsf::method::setter
when appropriate.
-In the next step, we define properties, i.e. variables with accessors.
+In the next step, we define configurable instance variables which we
+call properties in NX.
XOTcl uses the method parameter
is a shortcut for creating multiple
-properties. For every parameter definition, XOTcl creates as well a
-slot object, keeping an extensible set of meta-data for every
-parameter. Slot objects can be as well created in XOTcl directly via
-the method slots
. NX provides a similar method named properties
.
+configurable variables with automically created accessors (methods for
+reading and writing of the variables). In NX, the prefered way to
+create configurable variables is to use the method property
. The
+method property
in NX is similar to variable
, but makes the
+variables configurable, which means that
+
+-
+
+one can specify the property as a non-positional parameter upon
+ creation of the object,
+
+
+-
+
+one can query the value via the method cget
, and
+
+
+-
+
+one can modify the value of the underlying variable via the method
+ configure
.
+
+
+
-Foo f1 -a 0
+
+puts [f1 b]
+
+f1 b 100
|
+
+puts [f1 cget -b]
+
+f1 configure -b 100
-Since every property defines a slot object, NX provides as well a
-scripted initialization for every slot object. Therefore, NX uses
-property
to define a single property, similar in syntax to method
-parameters (a braced pair to denote a variable with a default). The
-method property
can be used in NX on the class and on the object
-level (in XOTcl: just on the class level). When an property 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
, protected
or private
) can be used.
-
-
-
-The method variable
in NX is similar to property
, but it creates
-only slot objects in cases where internally needed. variable
it does
-neither provide object parameters, or naccessors.
-We show first the definition of properties simliar to the
-functionality provided as well by XOTcl and show afterwards how to use
-value constraints, optional parameters, etc. in NX.
+In general, NX allows to create variables and properties with and
+without accessor methods. The created accessor methods might be
+public
, protected
or public
. When the value none
is provided
+to -accessor
, no accessor will be created. This is actually the
+default in NX. In order to change the default behavior in NX, one can use
+::nx::configure defaultAccessor none|public|protected|private
.
-
-Class Foo -slots {
- Attribute a
- Attribute b -default 1
-}
-
-Foo f1 -a 0
-
-
-f1 b 100
-
-puts [f1 b]
+
|
+f1 a 100
+
+
+
+Similar to variable
, properties can be defined in NX on the class
+and on the object level.
+
+
+
+
+
+XOTcl |
+Next Scripting Language |
+
+
+
+
|
+
|
-
-
-
-
-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 {
- :property sex {
- :type "sex"
- :object method type=sex {name value} {
- switch -glob $value {
- m* {return m}
- f* {return f}
- default {
- error "expected sex but got $value"
- }
- }
- }
- }
-} |
-
@@ -2967,10 +2929,10 @@
-In XOTcl all object parameters were optional. Required parameters have
+
In XOTcl all configure parameters were optional. Required parameters have
to be passed to the constructor of the object.
-
NX allows to define optional and required object parameters (as
-well as method parameters). Therefore, object parameters can be used
+
NX allows to define optional and required configure parameters (as
+well as method parameters). Therefore, configure parameters can be used
as the single mechanism to parameterize objects. It is in NX not
necessary (and per default not possible) to pass arguments to the
constructor.
@@ -3114,12 +3076,236 @@
-
The Object parameters provided by a class for the initialization of
-instances can be introspected via /cls/ info parameter
(see
-[info_parameter]).
+
For the implementation of variables and properties, NX uses slot
+objects, which are an extension to the -slots
already available in
+XOTcl. While very for every property
in NX, a slot object is created,
+for performance reasons, not every variable
has a slot associated.
+
When an property 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 a parameter definition for the initialization of the
+ object (usable via a non-positional parameter during object
+ creation), and
+
+
+-
+
+register optionally an accessor function (setter), for which the usual
+ protection levels (public
, protected
or private
) can be used.
+
+
+
+
+
+
+
+
+
+XOTcl |
+Next Scripting Language |
+
+
+
+
+
+
+
+Class Foo -slots {
+ Attribute a
+ Attribute b -default 1
+}
+
+Foo f1 -a 0
+
+ |
+
+
+
+Class create Foo {
+ :property a
+ :property {b 1}
+}
+
+Foo create f1 -a 0
+
+ |
+
+
+
+
Since the slots are objects, the slot objects can be configured and
+parameterized like every other object in NX. Slot objects can be
+provided with a scripted initialization as well. We show first the
+definition of properties simliar to the functionality provided as well
+by XOTcl and show afterwards how to use value constraints, optional
+parameters, etc. in NX.
+
+
+
+
+
+
+XOTcl |
+Next Scripting Language |
+
+
+
+
+
+
+
+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 {
+ :property sex {
+ :type "sex"
+ :object method type=sex {name value} {
+ switch -glob $value {
+ m* {return m}
+ f* {return f}
+ default {
+ error "expected sex but got $value"
+ }
+ }
+ }
+ }
+} |
+
+
+
+
+
The configure parameters provided by a class for the initialization of
+instances can be introspected via /cls/ info configure parameters
+(see [info_configure_parameter]).
+
-
2.4.2. Method Parameters
+
2.4.2. Delete Variable Handlers
+
+
+
+
+
+
+XOTcl |
+Next Scripting Language |
+
+
+
+
+ |
+
+
+ /cls/ delete property /name/
+/obj/ delete object property /name/ |
+
+
+
+
+
+
+
2.4.3. Method Parameters
Method parameters are used to specify the interface of a single method
(what kind of values may be passed to a method, what default values
are provided etc.). The method parameters specifications in XOTcl 1
@@ -3258,7 +3444,7 @@
}
-
2.4.3. Return Value Checking
+
2.4.4. Return Value Checking
Return value checking is a functionality available in the Next
Scripting Framework, that was not yet available in XOTcl 1. A return
value checker assures that a method returns always a value satisfying
@@ -4713,7 +4899,12 @@
object
as usual.
-
2.6.8. List Slots and their definitions
+
+
Obtain information, how newly created object can be configured. The
+configuration of objects is performed in many languages over arguments
+to the constructors. NX has - what we think - a superiour approach for
+configuration via configure parameters. The configure parameter are
+defined by NX application programs usually via property
.
+
+
+
2.6.9. List Variable Handlers
+
+
+
+
+
- |
-
-
-
-/obj/ info object slot names \
- ?-type value? ?pattern?
-/cls/ info slot names \
- ?-type value? ?-closure? ?-source value? ?pattern? |
+XOTcl |
+Next Scripting Language |
+
+
|
+/cls/ info parameter
|
+
+/obj/ info lookup variables /pattern/
+
+
+/obj/ info variable definition /handle/
+/obj/ info variable name /handle/
+/obj/ info variable parameter /handle/
-
2.6.9. List Object parameters
+
2.6.10. List Slots
-
+/obj/ info object slots ?-type ...? ?pattern?
+/cls/ info slots \
+ ?-type value? ?-closure? ?-source value? ?pattern?
-/cls/ info parameter names ?name?
+
+/obj/ info lookup slots \
+ ?-type ...? ?-source ... ?pattern?
-/cls/ info parameter definitions ?name?
-
-/cls/ info parameter syntax ?name?
+
+/slotobj/ definition
+/slotobj/ name
+/slotobj/ parameter
-
2.6.10. List Filter or Mixins
+
2.6.11. 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
@@ -5103,7 +5263,7 @@
-
2.6.11. List definition of methods defined by aliases, setters or forwarders
+
2.6.12. List definition of methods defined by aliases, setters or forwarders
As mentioned earlier, info method definition
can be used on every
kind of method. The same call can be used to obtain the definition of
a scripted method, a method-alias, a forwarder or a setter method.
@@ -5153,7 +5313,7 @@
-
2.6.12. List Method-Handles
+
2.6.13. 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
@@ -5224,7 +5384,7 @@
-
2.6.13. List type of a method
+
2.6.14. List type of a method
The method info ?object? method type
is new in NX to obtain the type of the
specified method.
@@ -5298,7 +5458,7 @@
-
2.6.14. List the scope of mixin classes
+
2.6.15. List the scope of mixin classes
NX provides a richer set of introspection options to obtain
information, where mixins classes are mixed into.
@@ -5418,7 +5578,7 @@
-
2.6.15. Check properties of object and classes
+
2.6.16. Check properties of object and classes
Similar as noted before, NX uses rather a hierarchical approach of
naming using multiple layers of subcommands).
@@ -5629,7 +5789,7 @@
-
2.6.16. Call-stack Introspection
+
2.6.17. 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
@@ -6469,8 +6629,8 @@