Index: doc/example-scripts/traits-composite.tcl =================================================================== diff -u -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 -rac2bbda827dff056beb23cf8400ab77b6996d1e8 --- doc/example-scripts/traits-composite.tcl (.../traits-composite.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) +++ doc/example-scripts/traits-composite.tcl (.../traits-composite.tcl) (revision ac2bbda827dff056beb23cf8400ab77b6996d1e8) @@ -19,13 +19,13 @@ # # Define the methods provided by this trait: # - :public object method atStart {} {expr {[:position] == [:minPosition]}} - :public object method atEnd {} {expr {[:position] == [:maxPosition]}} - :public object method setToStart {} {set :position [:minPosition]} - :public object method setToEnd {} {set :position [:maxPosition]} - :public object method maxPosition {} {llength ${:collection}} - :public object method minPosition {} {return 0} - :public object method nextPosition {} {incr :position 1} + :public method atStart {} {expr {[:position] == [:minPosition]}} + :public method atEnd {} {expr {[:position] == [:maxPosition]}} + :public method setToStart {} {set :position [:minPosition]} + :public method setToEnd {} {set :position [:maxPosition]} + :public method maxPosition {} {llength ${:collection}} + :public method minPosition {} {return 0} + :public method nextPosition {} {incr :position 1} # The trait requires a method "position" and a variable "collection" # from the base class or other traits. The definition is incomplete @@ -43,8 +43,8 @@ # # Methods provided by this trait: # - :public object method on {collection} {set :collection $collection; :setToStart} - :public object method next {} { + :public method on {collection} {set :collection $collection; :setToStart} + :public method next {} { if {[:atEnd]} {return ""} else { set r [lindex ${:collection} ${:position}] :nextPosition @@ -67,8 +67,8 @@ # # Methods provided by this trait: # - :public object method on {collection} {set :collection $collection; :setToEnd} - :public object method nextPut {element} { + :public method on {collection} {set :collection $collection; :setToEnd} + :public method nextPut {element} { lappend :collection $element :nextPosition return "" @@ -97,3 +97,4 @@ ? {r1 atEnd} 0 ? {r1 next} a ? {r1 next} b +