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

commits at source.squeak.org commits at source.squeak.org
Thu Jun 10 18:48:37 UTC 2021

A new version of Collections was added to project The Inbox:

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

Name: Collections-ct.948
Author: ct
Time: 10 June 2021, 8:48:33.981588 pm
UUID: 551e6fa7-8f93-ab48-8ab6-17fc5191f48c
Ancestors: Collections-eem.944

Handle binary selectors in Symbol >> #asSortFunction. As long as we do not officially deprecate Symbol >> #value:value:, the current state is a bit disappointing.


	'hello' sorted: #<=> asSortFunction.
	"...in the past, we needed to write all this prose instead:"
	'hello' sorted: [:someCharacter :someOtherCharacter | someCharacter <=> someOtherCharacter] asSortFunction.

=============== Diff against Collections-eem.944 ===============

Item was changed:
  ----- Method: Symbol>>asSortFunction (in category '*Collections-SortFunctions-converting') -----
+ 	"Return a SortFunction around the receiver. If the receiver is a 2-arg symbol, it is assumed it will do the collation directly itself, returning -1, 0, or 1. If the receiver is a one-arg symbol, it will be evaluated for each a and b and of the sort input, and the result of sending <=> to those will be used."
+ 	self numArgs = 0 ifTrue: [^PropertySortFunction property: self].
+ 	self numArgs = 1 ifTrue: [^CollatorBlockFunction usingBlock: self].
- 	"Return a SortFunction around the receiver, where the receiver will be used as a unary message to send to both a and b during sorting, and then the result of said send will be collated in ascending order using the <=> method."
- 	"#('abc' 'de' 'fghi') sorted: #size ascending >>> #('de' 'abc' 'fghi')"
+ 	self error: 'Cant be converted to sort function. It should has one or two args'.!
- 	^PropertySortFunction property: self!

More information about the Squeak-dev mailing list