(1) If you want (aSet collect: collectBlock) do: doBlock
������ you can write exactly that.�� Nothing stops you, and it will
������ be as clear and reliable as any use of Set>>collect:, which
������ is to say NOT VERY CLEAR OR RELIABLE AT ALL.
(2) #collect:then{Do:Select:Reject:} had no other purpose than
������ to avoid creating an intermediate and otherwise useless
������ collection.�� If you are not trying to involve an intermediate
������ set then it just plain wrong to use #collect:thenDo:.
(3) Oddly enough, the reason that #collect:thenDo: exists in my
������ library is that I copied it from Squeak, at a time when it had
������ the same definition as Pharo and ST/X.�� Had I known of the change
������ in Squeak I would have bitterly opposed it.�� The comment in the
������ current Squeak code, that it is for readability, is 100% the
������ reverse of the truth.�� Using the version with parentheses is WAY
������ clearer than using the portmanteau method.�� Sigh.�� I see they
������ broke #collect:thenSelect: in the same way.
(4) Let me offer you another member of the #collect:then* family.
������ Collection
���������� collect: collectBlock thenInject: initial into: injectBlock
�������������� |r|
�������������� r := initial.
�������������� self do: [:each |
������������������ r := injectBlock value: r value: (collectBlock value: each)].
�������������� ^r
������ #(now is the hour for us to say goodbye) asSet
���������� collect: [:each | each size]
���������� thenInject: 0 into: [:acc :each | acc + each]
��=> 29
������ (#(now is the hour for us to say goodbye) asSet
���������� collect: [:each | each size])
���������� inject: 0 into: [:acc :each | acc + each]
��=> 16
���� That is, it would be WRONG to implement #collect:thenInject:into:
���� as #collect: followed by #inject:into:.�� The point is NOT to
���� coalesce things that the receiver might (in general, incorrectly)
���� regard as equal.
(5) The bottom line is that if #collect:thenDo: and its relatives did
������ not have their present semantics in Pharo (and ST/X), they would
������ need to be reinvented, with names that were not as clear.
(1) Just to repeat for emphasis, if you *want* (_ collect: _) do: _
������ then that is exactly what you should write.�� There is no
������ excuse for using #collect:thenDo: in that case.�� It is NOT
������ clearer to do so.�� And you should imagine me jumping up and
������ down screaming that sending #collect: to a set is a bad code
������ smell which demands very explicit documentation as to why you
������ (for example) want a Set to answer a Set but an IdentitySet
������ to also answer a Set, not the expected IdentitySet.�� (I have
������ been bitten by that more than once.)