Index: doc/next-tutorial/next-tutorial.html
===================================================================
diff -u -rd725e5e4cfc9f89d78e781e6ce27900e199ba8c5 -rd303212e06bfd89c57038a26ba54f9f86e941601
--- doc/next-tutorial/next-tutorial.html (.../next-tutorial.html) (revision d725e5e4cfc9f89d78e781e6ce27900e199ba8c5)
+++ doc/next-tutorial/next-tutorial.html (.../next-tutorial.html) (revision d303212e06bfd89c57038a26ba54f9f86e941601)
@@ -735,8 +735,8 @@
+}
Typically, classes are defined in NX via nx::Class create
, followed
by the name of the new class (here: Stack
). The definition of the
stack placed between curly braces and contains here just the method
@@ -952,25 +933,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- | |
+s1 destroy
Now we want to use the stack. The code snippet in Listing 3 shows how to use the class Stack in a script.
Since NX is based on Tcl, the script will be called with the Tcl shell
tclsh
. In the Tcl shell we have to require package nx
to use the
@@ -1051,22 +1014,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- | nx::Object create stack {
+nx::Object create stack {
:object variable things {}
@@ -1080,7 +1028,7 @@
set :things [lrange ${:things} 1 end]
return $top
}
-} |
+}
The example in Listing 5 defines the
object stack
in a very similar way as the class Stack
. But the
following points are different.
@@ -1158,31 +1106,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- | nx::Class create Safety {
+nx::Class create Safety {
|
+}
Note that all the methods of the class Safety
end with next
.
This command is a primitive command of NX, which calls the
same-named method with the same argument list as the current
@@ -1230,29 +1154,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- | % package require nx
+% package require nx
2.0
% source Stack.tcl
::Stack
@@ -1273,7 +1175,7 @@
::Stack ::nx::Object
% s2 info precedence
-::Safety ::Stack ::nx::Object |
+::Safety ::Stack ::nx::Object
When the method push
of s2
is called, first the method of the
mixin class Safety
will be invoked that increments the counter and
continues with next
to call the shadowed method, here the method
@@ -1318,20 +1220,13 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- | |
+SafeStack create s3
The difference of a per-class mixin and an per-object mixin is that
the per-class mixin is applicable to all instances of the
class. Therefore, we call these mixins also sometimes instance mixins.
@@ -1373,18 +1268,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- | Stack create s4 {
+Stack create s4 {
|
+}
The program snippet in Listing 12 defines an instance s4
of the class
Stack
and provides an object specific method for push
to implement
an integer stack. The method pull
is the same for the integer stack
@@ -1420,17 +1304,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- | nx::Class create IntegerStack -superclass Stack {
+nx::Class create IntegerStack -superclass Stack {
|
+}
An alternative approach is shown in
Listing 13, where the class
IntegerStack
is defined, using the same method definition
@@ -1473,31 +1347,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- | nx::Class create Stack2 {
+nx::Class create Stack2 {
:public object method available_stacks {} {
return [llength [:info instances]]
@@ -1520,7 +1370,7 @@
Stack2 create s1
Stack2 create s2
-puts [Stack2 available_stacks] |
+puts [Stack2 available_stacks]
The class Stack2
in Listing 14 consists of the
earlier definition of the class Stack
and is extended by the
class-specific method available_stacks
, which returns the
@@ -1591,18 +1441,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- | nx::Class create Foo {
+nx::Class create Foo {
:method foo args {...}
|
+}
Listing 16 shows a method foo
of some class Foo
referring to differently scoped variables.
@@ -1662,34 +1501,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- | |
+puts "The name of s1 is [s1 cget -name]"
By defining name
and birthday
as properties of Person
, NX makes
these configurable. When we create an instance of Person
named
p1
, we can provide a value for e.g. the name by specifying -name
@@ -1772,22 +1584,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- | nx::Class create Base {
+nx::Class create Base {
:variable x 1
}
@@ -1801,7 +1598,7 @@
Derived create d1
|
+
Note that the variable definitions are inherited in the same way as
properties. The example in Listing 19 shows a
class Derived
that inherits from Base
. When an instance d1
is
@@ -1820,26 +1617,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- | nx::Class create Base2 {
+nx::Class create Base2 {
:method init {} {
set :x 1
@@ -1857,7 +1635,7 @@
}
Derived2 create d2 |
+Derived2 create d2
In many other object oriented languages, the instance variables are
initialized solely by the constructor (similar to class Derived2
in
Listing 20). This approach is certainly
@@ -1904,21 +1682,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- | |
+fido bark
In the example above we create a class Dog
with a scripted method
named bark
. The method body defines the code, which is executed when
the method is invoked. In this example, the method bar
prints out a
@@ -1980,32 +1744,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- | nx::Class create Dog {
+nx::Class create Dog {
:public method bark {} { puts "[self] Bark, bark, bark." }
:method init {} { Tail create [self]::tail}
}
@@ -2029,7 +1768,7 @@
fido::tail length set 10
fido::tail length set "Hello" |
+fido::tail length set "Hello"
Listing 22 shows an extended example, where every dog
has a tail. The object tail
is created as a subobject of the dog in
the constructor init
. The subobject can be accessed by providing the
@@ -2050,26 +1789,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- | nx::Class create Dog {
+nx::Class create Dog {
:public method bark {} { puts "[self] Bark, bark, bark." }
:method init {} {
Tail create [self]::tail
@@ -2087,7 +1807,7 @@
fido wag |
+fido wag
Listing 23 again extends the example by adding a
forwarder named wag
to the object (e.g. fido
). The forwarder
redirects all calls of the form fido wag
with arbitrary arguments to
@@ -2133,20 +1853,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- | nx::Class create Dog {
+nx::Class create Dog {
:public method bark {} { puts "[self] Bark, bark, bark." }
Dog create fido
fido warn |
+fido warn
Listing 24 extends the last example by defining an
alias for the method bark
. The example only shows the bare
mechanism. In general, method aliases are very powerful means for
@@ -2206,29 +1913,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- | nx::Class create Foo {
+nx::Class create Foo {
:public method foo {} {
@@ -2249,7 +1934,7 @@
f1 foo
f1 helper |
+f1 helper
The example above uses :protected method helper …
. We could have
used here as well :method helper …
, since the default method
call-protection is already protected.
@@ -2269,21 +1954,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- | nx::Class create Base {
+nx::Class create Base {
:private method helper {a b} {expr {$a + $b}}
:public method foo {a b} {: -local helper $a $b}
}
@@ -2296,7 +1967,7 @@
s1 foo 3 4 ;s1 bar 3 4 ;s1 helper 3 4 ; |
+s1 helper 3 4 ;
The base class implements a public method foo
using the helper
method named helper
. The derived class implements a as well a public
method bar
, which is also using a helper method named helper
. When
@@ -2335,32 +2006,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- | D create d1
puts [d1 x get] ;puts [d1 bar x] ; |
+puts [d1 bar x] ;
Without the private
definition of the property, the definition of
property x
in class D
would shadow the
definition of the property in the superclass C
for its instances
@@ -2417,22 +2063,14 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- | nx::Class create C {
+nx::Class create C {
:public method foo {} {return 1}
:create c1
}
c1 foo |
+c1 foo
There are many programming languages that only allow these types of methods.
However, NX also allows methods to be defined on objects.
@@ -2462,26 +2100,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- | nx::Class create C {
+nx::Class create C {
:public method foo {} {return 1}
:create c1 {
:public object method foo {} {return 2}
@@ -2499,7 +2118,7 @@
nx::Object create o1 {
:public object method baz {} {return 4}
}
-o1 baz |
+o1 baz
3.4.3. Class Methods
@@ -2529,32 +2148,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- | nx::Class create C {
+nx::Class create C {
|
+c1 bar
In some other object oriented programming languages, class methods
are called "static methods".
@@ -2614,21 +2208,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- | nx::Class create C {
+nx::Class create C {
|
+c1 string length "hello world"
3.6. Method Resolution
@@ -2665,33 +2245,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- | nx::Class create C {
+nx::Class create C {
:public method foo {} {
return "C foo: [next]"
}
@@ -2716,7 +2270,7 @@
d1 info precedence
- |
+
Consider the example in
Listing 32. When the method
foo
is invoked on object d1
, the object method has the highest
@@ -2744,31 +2298,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- | nx::Class create M1 {
+nx::Class create M1 {
:public method foo {} { return "M1 foo: [next]"}
}
nx::Class create M2 {
@@ -2791,7 +2321,7 @@
d1 info precedence
- |
+
The example in Listing 33 is
an extension of the previous example. We define here two additional
classes M1
and M2
which are used as per-object and per-class
@@ -2811,23 +2341,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- | |
+d1 bar
In the first line of the body of method bar
, the method foo
is
called as usual with an implicit receiver, which defaults to the
current object (therefore, the call is equivalent to d1 foo
). The
@@ -2935,43 +2449,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- | nx::Object create o1 {
+nx::Object create o1 {
|
+o1 baz -- -y
Consider the example in Listing 35. The method
foo
has the argument list x y
. This means that the first argument
is passed in an invocation like o1 foo 1 2
to x
(here, the value
@@ -3052,28 +2530,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- | nx::Object create o2 {
+nx::Object create o2 {
|
+o2 foo 1
The example in Listing 36 defined method foo
with one required and one optional positional parameter. For this
purpose we use the parameter options required
and optional
. The
@@ -3131,27 +2588,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- | nx::Object create o3 {
+nx::Object create o3 {
|
+o3 bar
In order to define a default value for a parameter, the parameter
specification must be of the form of a 2 element list, where the
second argument is the default value. See for an example in
@@ -3221,27 +2658,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- | nx::Object create o4 {
+nx::Object create o4 {
|
+o4 foo a
Value contraints are specified as parameter options in the parameter
specifications. The parameter specification x:integer
defines x
as
a required positional parmeter which value is constraint to an
@@ -3282,35 +2699,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- | |
+o5 work -person gustaf -project nx
The native checkers object
, class
, metaclass
and baseclass
can
be further specialized with the parameter option type
to restrict
the permissible values to instances of certain classes. We can use for
@@ -3371,50 +2760,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- | d1 bar green good
-d1 bar pink bad |
+d1 bar pink bad
In order to define a checker groupsize
a method of the name
type=groupsize
is defined. This method receives two arguments,
name
and value
. The first argument is the name of the parameter
@@ -3514,33 +2860,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- | nx::Object create o6 {
+nx::Object create o6 {
:public object method baz {x:integer,1..n} {
puts "x=$x"
}
-} |
+}
Listing 42 contains three examples for
positional parameters with different multiplicities. Multiplicity is
often combined with value constraints. A parameter specification of
@@ -3654,34 +2974,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- | |
+puts "The name of s1 is [s1 cget -name]"
The class Person
has two properties name
and birthday
, where the
property name
is required, the property birthday
is not. The
class Student
is a subclass of Person
with the additional required
@@ -3764,21 +3057,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- | Configure parameters for Person p1:
+Configure parameters for Person p1:
Command:
p1 info lookup syntax configure
Result:
@@ -3791,7 +3070,7 @@
Result:
?-oncampus /boolean/? -matnr /value/ -name /value/
?-birthday /value/? ?-object-mixins /mixinreg .../? ?-class /class/?
- ?-object-filters /filterreg .../? ?/__initblock/? |
+ ?-object-filters /filterreg .../? ?/__initblock/?
The given paramter show, how (a) objects can be configured
at runtime or (b) how new instances can be configured
at creation time via the new
or create
methods.
@@ -3848,20 +3127,13 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- | Configure parameter for class nx::Class
+Configure parameter for class nx::Class
Command:
nx::Class info lookup syntax configure
Result:
?-superclass /class .../? ?-mixins /mixinreg .../?
?-filters /filterreg .../? ?-object-mixins /mixinreg .../?
- ?-class /class/? ?-object-filters /filterreg .../? ?/__initblock/? |
+ ?-class /class/? ?-object-filters /filterreg .../? ?/__initblock/?
4.3.3. User defined Parameter Types
@@ -3962,17 +3234,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- | ::nx::Object create o {
+::nx::Object create o {
:object method unknown {called_method args} {
puts "Unknown method '$called_method' called"
}
@@ -3981,7 +3243,7 @@
o foo 1 2 3
- |
+
Without any provision of an unknown method handler, an error will be
raised, when an unknown method is called.
@@ -4006,29 +3268,7 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- | ::nx::Class public object method __unknown {name} {
+::nx::Class public object method __unknown {name} {
puts "***** __unknown called with <$name>"
@@ -4049,7 +3289,7 @@
} |
+}
The Next Scripting Framework allows to add, query, delete and list unknown handlers.
Listing 50: Unknown Handler registration
@@ -4063,16 +3303,11 @@
.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;}
.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;}
-
+