Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.826.mcz==================== Summary ====================
Name: Collections-nice.826
Author: nice
Time: 25 April 2019, 2:22:58.283343 pm
UUID: 116c66c9-4c34-5c4f-a9d9-c21d3141c5ea
Ancestors: Collections-fn.825
Fix bugs in LazyCharacterSet
The block instance variable should not refer to itself, or we'll get an infinite recursion when evaluating.
Thus when modifying the collection (#add: #addAll: #remove: #removeAll:), we must use a temporary reference to block
Fix another typo bug in removeAll s/include:/includes:/
Unfortunately, there was a Player>>#include: preventing an easy detection of the bug
Example:
(CharacterSet separators complement reject: [:e | e isVowel])
removeAll: ($0 to: $9);
includes: $3.
=============== Diff against Collections-fn.825 ===============
Item was changed:
----- Method: LazyCharacterSet>>add: (in category 'adding') -----
add: aCharacter
+ | oldBlock |
+ oldBlock := block.
+ block := [:c | c = aCharacter or: [oldBlock value: c]].
- self block: [:c | c = aCharacter or: [block value: c]].
^aCharacter!
Item was changed:
----- Method: LazyCharacterSet>>addAll: (in category 'adding') -----
addAll: aCollection
+ | oldBlock |
+ oldBlock := block.
+ block := [:c | (aCollection includes: c) or: [oldBlock value: c]].
- self block: [:c | (aCollection includes: c) or: [block value: c]].
^aCollection!
Item was changed:
----- Method: LazyCharacterSet>>remove: (in category 'removing') -----
remove: aCharacter
+ | oldBlock |
+ oldBlock := block.
+ block := [:c | (c = aCharacter) not and: [oldBlock value: c]].
- self block: [:c | (c = aCharacter) not and: [block value: c]].
^aCharacter!
Item was changed:
----- Method: LazyCharacterSet>>removeAll: (in category 'removing') -----
removeAll: aCollection
+ | oldBlock |
+ oldBlock := block.
+ block := [:c | (aCollection includes: c) not and: [oldBlock value: c]].
- self block: [:c | (aCollection include: c) not and: [block value: c]].
^aCollection!