[squeak-dev] The Inbox: Collections-ct.923.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Mon Jan 25 11:15:19 UTC 2021


If we want to optimize this for code artifacts, why not add that extra space *all the time*. Then again, only #storeOn: should do that, right? Putting so much effort into making #printOn: fit for something it is not meant to be, worries me. :-/

Best,
Marcel
Am 24.01.2021 16:53:54 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.923.mcz

==================== Summary ====================

Name: Collections-ct.923
Author: ct
Time: 24 January 2021, 4:53:44.716273 pm
UUID: bd630b83-a77e-cb4f-a008-246786a5c7d8
Ancestors: Collections-mt.919

Fixes printString representation of Associations and Dictionarys to avoid ambiguous selectors. As a consequence, reevalabuality is not limited any longer.

Examples:
1 -> 2. "--> 1->2"
1 -> -2. "--> 1 -> -2"
Dictionary new at: -1 put: 1; at: 1 put: -1; yourself. "--> a Dictionary(-1->1 1 -> -1)"

=============== Diff against Collections-mt.919 ===============

Item was changed:
----- Method: Association>>printOn: (in category 'printing') -----
printOn: aStream
+
| arrow |
super printOn: aStream.
+
+ "Avoid AmbiguousSelector warnings when evaluating the stream as Smalltalk code."
+ arrow := ((key isSymbol and: [key isBinary])
+ or: [(value printStringLimitedTo: 1) beginsWith: '-'])
+ ifTrue: [' -> ']
+ ifFalse: ['->'].
- "If the key is a binary selector and we don't use whitespace, we will stream (key, '->') asSymbol."
- arrow := (key isSymbol and: [key isBinary]) ifTrue: [' -> '] ifFalse: ['->'].
aStream nextPutAll: arrow.
+
+ value printOn: aStream.!
- value printOn: aStream!

Item was changed:
----- Method: Dictionary>>printElementsOn: (in category 'printing') -----
printElementsOn: aStream
aStream nextPut: $(.
self size > 100
ifTrue: [aStream nextPutAll: 'size '.
self size printOn: aStream]
ifFalse: [self keysInOrder
+ do: [:key | aStream print: (self associationAt: key)]
+ separatedBy: [aStream space]].
- do: [:key | aStream print: key;
- nextPutAll: '->';
- print: (self at: key);
- space]].
aStream nextPut: $)!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210125/e89ccc56/attachment.html>


More information about the Squeak-dev mailing list