Index: doc/tutorial2.html =================================================================== diff -u -r9ee8d01537389a88bbbb560acb5f811d3e77422a -r210eab6d9149846d5d6a6a8e0fa74e232ca5b6de --- doc/tutorial2.html (.../tutorial2.html) (revision 9ee8d01537389a88bbbb560acb5f811d3e77422a) +++ doc/tutorial2.html (.../tutorial2.html) (revision 210eab6d9149846d5d6a6a8e0fa74e232ca5b6de) @@ -308,24 +308,24 @@ # Class create Stack { - .method init {} { # Constructor - set .things "" + :method init {} { # Constructor + set :things "" } - .method push {thing} { - set .things [linsert ${.things} 0 $thing] + :method push {thing} { + set :things [linsert ${:things} 0 $thing] return $thing } - .method pop {} { - set top [lindex ${.things} 0] - set .things [lrange ${.things} 1 end] + :method pop {} { + set top [lindex ${:things} 0] + set :things [lrange ${:things} 1 end] return $top } }

-The three methods are defined via .method (which means: +The three methods are defined via :method (which means: define a method for the current class). Variables are set with the Tcl command set. Variable names starting with a dot "." are treated as instance variables (variables of an instance of the @@ -380,16 +380,16 @@ # Object create stack { - set .things "" + set :things "" - .method push {thing} { - set .things [linsert ${.things} 0 $thing] + :method push {thing} { + set :things [linsert ${:things} 0 $thing] return $thing } - .method pop {} { - set top [lindex ${.things} 0] - set .things [lrange ${.things} 1 end] + :method pop {} { + set top [lindex ${:things} 0] + set :things [lrange ${:things} 1 end] return $top } } @@ -408,19 +408,19 @@ # Class create Safety { - .method init {} { # Constructor - set .count 0 + :method init {} { # Constructor + set :count 0 next } - .method push {thing} { - incr .count + :method push {thing} { + incr :count next } - .method pop {} { - if {${.count} == 0} then { error "Stack empty!" } - incr .count -1 + :method pop {} { + if {${:count} == 0} then { error "Stack empty!" } + incr :count -1 next } } @@ -477,7 +477,7 @@ Stack create s4 { - .method push {value} { + :method push {value} { if {![string is integer $value]} { error "value $value is not an integer" } @@ -507,8 +507,8 @@ Class create Stack { # ... - .object method available_stacks {} { - return [llength [.info instances]] + :object method available_stacks {} { + return [llength [:info instances]] } } @@ -585,7 +585,7 @@

We may add a player by using method. Methods can be defined -in XOTcl2 either by .method in the class creation block, or +in XOTcl2 either by :method in the class creation block, or via "ClassName method ...". The added players (as well as other club members) are aggregated in the object of the soccer team (denoted by :: namespace syntax). @@ -606,7 +606,7 @@ SoccerTeam method transferPlayer {playername destinationTeam} { # We use the aggregation introspection option children in order # to get all club members - foreach player [.info children] { + foreach player [:info children] { # But we only remove matching playernames of type "Player". We do # not want to remove another club member type who has the same # name. @@ -624,12 +624,12 @@

   SoccerTeam method printMembers {} {
-    puts "Members of ${.name}:"
-    foreach m [.info children] {puts "  [$m name]"}
+    puts "Members of ${:name}:"
+    foreach m [:info children] {puts "  [$m name]"}
   }
   SoccerTeam method printPlayers {} {
-    puts "Players of ${.name}:"
-    foreach m [.info children] {
+    puts "Players of ${:name}:"
+    foreach m [:info children] {
       if {[$m info is type Player]} {puts "  [$m name]"}
     }
   }
@@ -659,7 +659,7 @@
 

   Player instinvar {
-    {${.playerRole} in [list "NONE" "PLAYER" "GOALY"]}
+    {${:playerRole} in [list "NONE" "PLAYER" "GOALY"]}
   }
 

@@ -694,8 +694,8 @@

   Class create Singer {
 
-    .method sing text {
-      puts "${.name} sings: $text, lala."
+    :method sing text {
+      puts "${:name} sings: $text, lala."
     }
   }
 
@@ -723,7 +723,7 @@

   Player method class args {
-    unset .playerRole
+    unset :playerRole
     next
   }
 
@@ -776,7 +776,7 @@

   Class TransferObserver {
-    .method transferPlayer {pname destinationTeam} {
+    :method transferPlayer {pname destinationTeam} {
       puts "Player '$pname' is transfered to Team '[$destinationTeam name]'"
       next
     }