Generalize visitor pattern and define #visit...:with: -methods instead
of #encode...:with:
--- a/Block.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Block.st Fri Jun 11 20:12:49 2004 +0200
@@ -610,13 +610,6 @@
"Created: / 31.3.1998 / 15:46:17 / cg"
! !
-!Block methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
-
- ^ anEncoder encodeBlock:self with:aParameter
-! !
-
!Block methodsFor:'error handling'!
invalidCodeObject
@@ -2061,10 +2054,17 @@
"
! !
+!Block methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+
+ ^ aVisitor visitBlock:self with:aParameter
+! !
+
!Block class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.137 2004-02-27 20:46:26 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.138 2004-06-11 18:11:34 stefan Exp $'
! !
Block initialize!
--- a/Boolean.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Boolean.st Fri Jun 11 20:12:49 2004 +0200
@@ -158,15 +158,6 @@
^ self
! !
-!Boolean methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
-
- anEncoder encodeBoolean:self with:aParameter
-
-
-! !
-
!Boolean methodsFor:'printing & storing'!
printOn:aStream
@@ -218,8 +209,15 @@
! !
+!Boolean methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+
+ ^ aVisitor visitBoolean:self with:aParameter
+! !
+
!Boolean class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.30 2004-04-07 12:59:37 werner Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Boolean.st,v 1.31 2004-06-11 18:12:22 stefan Exp $'
! !
--- a/Character.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Character.st Fri Jun 11 20:12:49 2004 +0200
@@ -1431,13 +1431,6 @@
!Character methodsFor:'encoding'!
-encodeOn:anEncoder with:aParameter
-
- anEncoder encodeCharacter:self with:aParameter
-
-
-!
-
rot13
"Usenet: from `rotate alphabet 13 places']
The simple Caesar-cypher encryption that replaces each English
@@ -2765,8 +2758,15 @@
! !
+!Character methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+
+ ^ aVisitor visitCharacter:self with:aParameter
+! !
+
!Character class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.120 2004-04-08 12:53:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.121 2004-06-11 18:12:49 stefan Exp $'
! !
--- a/Integer.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Integer.st Fri Jun 11 20:12:49 2004 +0200
@@ -1904,15 +1904,6 @@
"Modified: 28.7.1997 / 19:08:11 / cg"
! !
-!Integer methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
-
- anEncoder encodeInteger:self with:aParameter
-
-
-! !
-
!Integer methodsFor:'helpers'!
gcd_helper:anInteger
@@ -3293,6 +3284,13 @@
"Modified: 18.7.1996 / 12:44:33 / cg"
! !
+!Integer methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+
+ ^ aVisitor visitInteger:self with:aParameter
+! !
+
!Integer::ModuloNumber class methodsFor:'documentation'!
copyright
@@ -3454,7 +3452,7 @@
!Integer class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.167 2004-04-27 12:33:52 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.168 2004-06-11 18:12:06 stefan Exp $'
! !
Integer initialize!
--- a/Interval.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Interval.st Fri Jun 11 20:12:49 2004 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -13,10 +13,10 @@
"{ Package: 'stx:libbasic' }"
ReadOnlySequenceableCollection subclass:#Interval
- instanceVariableNames:'start stop step'
- classVariableNames:''
- poolDictionaries:''
- category:'Collections-Sequenceable'
+ instanceVariableNames:'start stop step'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Collections-Sequenceable'
!
!Interval class methodsFor:'documentation'!
@@ -24,7 +24,7 @@
copyright
"
COPYRIGHT (c) 1989 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -45,22 +45,22 @@
examples:
- (1 to:10) do:[:i | Transcript showCR:i]
+ (1 to:10) do:[:i | Transcript showCR:i]
notice, that this is semantically equivalent to:
- 1 to:10 do:[:i | Transcript showCR:i]
+ 1 to:10 do:[:i | Transcript showCR:i]
however, the second is preferred, since loops using to:do: are
much faster and do not create temporary garbage objects.
Therefore, Intervals are generally NOT used for this kind of loops.
- (1 to:10) asArray
+ (1 to:10) asArray
- (1 to:10 by:2) asOrderedCollection
+ (1 to:10 by:2) asOrderedCollection
[author:]
- Claus Gittinger
+ Claus Gittinger
"
! !
@@ -142,7 +142,7 @@
step
"return the step increment of the range.
OBSOLETE:
- Please use #increment for ST-80 compatibility."
+ Please use #increment for ST-80 compatibility."
^ step
!
@@ -246,15 +246,6 @@
"
! !
-!Interval methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
- "this is special. Some encoders want to encode this as a sequenceable collection,
- some want to encode a less expensive representation"
-
- anEncoder encodeInterval:self with:aParameter
-! !
-
!Interval methodsFor:'enumerating'!
collect:aBlock
@@ -266,7 +257,7 @@
newCollection := self species new:(self size).
self do:[:each |
- newCollection add:(aBlock value:each)
+ newCollection add:(aBlock value:each)
].
^ newCollection
@@ -333,7 +324,7 @@
newColl := self species new:(self size).
self do:[:each |
- (aBlock value:each) ifTrue:[newColl add:each]
+ (aBlock value:each) ifTrue:[newColl add:each]
].
^ newColl
@@ -360,8 +351,8 @@
aStream nextPutAll:' to:'.
stop printOn:aStream.
step ~= 1 ifTrue:[
- aStream nextPutAll:' by:'.
- step printOn:aStream.
+ aStream nextPutAll:' by:'.
+ step printOn:aStream.
].
"
@@ -477,13 +468,13 @@
"return the number of elements in the collection"
(step < 0) ifTrue:[
- (start < stop) ifTrue:[
- ^ 0
- ].
- ^ stop - start // step + 1
+ (start < stop) ifTrue:[
+ ^ 0
+ ].
+ ^ stop - start // step + 1
].
(stop < start) ifTrue:[
- ^ 0
+ ^ 0
].
^ stop - start // step + 1
! !
@@ -544,8 +535,17 @@
"
! !
+!Interval methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+ "this is special. Some encoders want to encode this as a sequenceable collection,
+ some want to encode a less expensive representation"
+
+ ^ aVisitor visitInterval:self with:aParameter
+! !
+
!Interval class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.40 2004-06-07 09:02:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.41 2004-06-11 18:10:32 stefan Exp $'
! !
--- a/Set.st Fri Jun 11 19:55:26 2004 +0200
+++ b/Set.st Fri Jun 11 20:12:49 2004 +0200
@@ -595,15 +595,6 @@
keyArray := keyArray shallowCopy
! !
-!Set methodsFor:'encoding'!
-
-encodeOn:anEncoder with:aParameter
-
- anEncoder encodeSet:self with:aParameter
-
-
-! !
-
!Set methodsFor:'enumerating'!
do:aBlock
@@ -1088,6 +1079,13 @@
! !
+!Set methodsFor:'visiting'!
+
+acceptVisitor:aVisitor with:aParameter
+
+ ^ aVisitor visitSet:self with:aParameter
+! !
+
!Set::EmptySlot class methodsFor:'instance creation'!
basicNew
@@ -1101,7 +1099,7 @@
!Set class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.88 2003-10-09 21:06:56 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.89 2004-06-11 18:10:46 stefan Exp $'
! !
Set initialize!