The Trunk: Collections-mt.853.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-mt.853.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.853.mcz

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

Name: Collections-mt.853
Author: mt
Time: 9 September 2019, 10:09:35.326051 am
UUID: 9a52d97c-7987-b644-912a-974c709c7320
Ancestors: Collections-mt.851, Collections-mt.849

Merges Collections-mt.849.

Note that this does only mark certain messages as "to deprecate", which has not happened yet.

=============== Diff against Collections-mt.851 ===============

Item was changed:
+ ----- Method: Collection>>asCommaString (in category 'printing - obsolete') -----
- ----- Method: Collection>>asCommaString (in category 'printing') -----
  asCommaString
  "Return collection printed as 'a, b, c' "
 
+ self flag: #deprecate.
+ ^ self asArray joinSeparatedBy: ', '
- ^String streamContents: [:s | self asStringOn: s delimiter: ', ']
  !

Item was changed:
+ ----- Method: Collection>>asCommaStringAnd (in category 'printing - obsolete') -----
- ----- Method: Collection>>asCommaStringAnd (in category 'printing') -----
  asCommaStringAnd
  "Return collection printed as 'a, b and c' "
 
+ self flag: #deprecate.
  ^String streamContents: [:s | self asStringOn: s delimiter: ', ' last: ' and ']
  !

Item was changed:
+ ----- Method: Collection>>asStringOn:delimiter: (in category 'printing - obsolete') -----
- ----- Method: Collection>>asStringOn:delimiter: (in category 'printing') -----
  asStringOn: aStream delimiter: delimString
- "Print elements on a stream separated
- with a delimiter String like: 'a, b, c'
- Uses #asString instead of #print:."
 
+ self flag: #deprecate.
+ ^ self asArray joinOn: aStream separatedBy: delimString!
- self do: [:elem | aStream nextPutAll: elem asString]
- separatedBy: [aStream nextPutAll: delimString]!

Item was changed:
+ ----- Method: Collection>>asStringOn:delimiter:last: (in category 'printing - obsolete') -----
- ----- Method: Collection>>asStringOn:delimiter:last: (in category 'printing') -----
  asStringOn: aStream delimiter: delimString last: lastDelimString
  "Print elements on a stream separated
  with a delimiter between all the elements and with
  a special one before the last like: 'a, b and c'.
  Uses #asString instead of #print:
 
  Note: Feel free to improve the code to detect the last element."
 
  | n sz |
+ self flag: #deprecate.
+
  n := 1.
  sz := self size.
  self do: [:elem |
  n := n + 1.
  aStream nextPutAll: elem asString]
  separatedBy: [
  aStream nextPutAll: (n = sz ifTrue: [lastDelimString] ifFalse: [delimString])]!

Item was changed:
  ----- Method: Collection>>printElementsOn: (in category 'printing') -----
  printElementsOn: aStream
- "The original code used #skip:, but some streams do not support that,
- and we don't really need it."
 
+ self
+ printElementsOn: aStream
+ separatedBy: String space.!
- aStream nextPut: $(.
- self do: [:element | aStream print: element] separatedBy: [aStream space].
- aStream nextPut: $)!

Item was added:
+ ----- Method: Collection>>printElementsOn:separatedBy: (in category 'printing') -----
+ printElementsOn: aStream separatedBy: delimiter
+ "Do not use #print: on the delemiter to have more control over the output. Strings get quoted, Characters get prefixed, etc."
+
+ self
+ do: [:element | aStream print: element]
+ separatedBy: [aStream nextPutAll: delimiter asString].!

Item was changed:
  ----- Method: Collection>>printOn: (in category 'printing') -----
  printOn: aStream
  "Append a sequence of characters that identify the receiver to aStream."
 
  self printNameOn: aStream.
+
+ aStream nextPut: $(.
+ self printElementsOn: aStream.
+ aStream nextPut: $).
+ !
- self printElementsOn: aStream!

Item was changed:
+ ----- Method: Collection>>printOn:delimiter: (in category 'printing - obsolete') -----
- ----- Method: Collection>>printOn:delimiter: (in category 'printing') -----
  printOn: aStream delimiter: delimString
- "Print elements on a stream separated
- with a delimiter String like: 'a, b, c' "
 
+ self flag: #deprecate.
+ self
+ printElementsOn: aStream
+ separatedBy: delimString.!
- self do: [:elem | aStream print: elem] separatedBy: [aStream print: delimString]
- !

Item was changed:
+ ----- Method: Collection>>printOn:delimiter:last: (in category 'printing - obsolete') -----
- ----- Method: Collection>>printOn:delimiter:last: (in category 'printing') -----
  printOn: aStream delimiter: delimString last: lastDelimString
  "Print elements on a stream separated
  with a delimiter between all the elements and with
  a special one before the last like: 'a, b and c'
 
  Note: Feel free to improve the code to detect the last element."
 
  | n sz |
+ self flag: #deprecate.
  n := 1.
  sz := self size.
  self do: [:elem |
  n := n + 1.
  aStream print: elem]
  separatedBy: [
  n = sz
  ifTrue: [aStream print: lastDelimString]
  ifFalse: [aStream print: delimString]]!

Item was added:
+ ----- Method: SequenceableCollection>>joinOn: (in category 'printing') -----
+ joinOn: stream
+
+ ^ self joinOn: stream separatedBy: ''!

Item was added:
+ ----- Method: SequenceableCollection>>joinOn:separatedBy: (in category 'printing') -----
+ joinOn: stream separatedBy: aSeparator
+
+ self
+ do: [:ea | stream nextPutAll: ea asString]
+ separatedBy: [stream nextPutAll: aSeparator asString].!

Item was changed:
  ----- Method: SequenceableCollection>>joinSeparatedBy: (in category 'converting') -----
  joinSeparatedBy: aSeparator
+ "Returns a string, which is a concatenation of each element's string representation separated by another string.
+
+ August 2019 -- http://forum.world.st/The-Inbox-Collections-ct-827-mcz-td5099876.html
+ There was a discussion about whether to move this method up to Collection. We identified a trade-off between (iinterface) convenience and (result) predictability. In Collection, this method would be available for Set, too. However, random result order makes such a feature questionable. What would be the result of #(1 2 3) asSet joinSeparatedBy: '-'? For such scenarios, some people argued, it would be better to explicitely call #asArray and maybe explain why a non-sequenceable collection was used in the first place."
- "Returns a string, which is a concatenation of each element's string representation separated by another string."
 
  ^ String streamContents: [:stream |
+ self joinOn: stream separatedBy: aSeparator]!
- self
- do: [:ea | stream nextPutAll: ea asString]
- separatedBy: [stream nextPutAll: aSeparator asString]]!