From fa4f783d4557ad68c87eed2220c71073cc39b2ca Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 29 Nov 2009 23:26:41 +0000 Subject: [PATCH] smalltalk: Abstract out the common iteration protocol into a superclass. --- smalltalk-fringe.st | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/smalltalk-fringe.st b/smalltalk-fringe.st index 0d319da..653c31a 100644 --- a/smalltalk-fringe.st +++ b/smalltalk-fringe.st @@ -5,7 +5,19 @@ Smalltalk implementation of a `same-fringe' solver. Use GNU Smalltalk syntax -- it seems more Emacs-friendly. " -Object subclass: Node [ +Object subclass: BasicNode [ + + + iterator [ + "Return a new iterator to walk this node." + + + ^NodeIterator for: self + ] +] + +BasicNode subclass: Node [ | left right data | ^false ] - iterator [ - "Answer a new iterator to walk this node." - - - ^NodeIterator for: self - ] - inorderTell: aBlock tell: aNodeIterator [ "This is the hairy part of the iteration protocol. @@ -179,7 +184,7 @@ PositionableStream extend [ ] ] -Object subclass: LeafNode [ +BasicNode subclass: LeafNode [ @@ -201,13 +206,6 @@ recursive protocols used to handle Nodes.'> ^true ] - iterator [ - "Return a new iterator to walk this node." - - - ^NodeIterator for: self - ] - inorderTell: aBlock tell: aNodeIterator [ "This is the hairy part of the iteration protocol. -- 2.11.0