2017-11-05 9:52 GMT+01:00 Stephane Ducasse <stepharo.self@gmail.com>:
Hi nicolas
With current implementation, collatedInFrench would have to use a block (thru a CollatorBlockFunction which is a proxy to the block in a SortFunction disguise):
Symbol>>collatedInFrench "interpret self as a property" ^[:a :b | FrenchCollator collate: (self value: a) with: (self value: b)]
But IMO SortByPropertyFunction should better feed a reified CollatorFunction, or said differently a SortFunction, as Denis said.
(I should say that I do not like collator as a name. It does not mean anything to me.)
Then use Sorter. Now in general I think that we are abusing blocks like in Glamour
(because we want compact syntax). My rule of thumb to compare little class vs. block is - do we have optional state? - do we have many arguments (where we have to learn by heart the order)?
You forgot one rule: - is the block replicated in many places? (that rule should include client libraries, not only kernel image)
Symbol>>collatedInFrench ^FrenchCollator new onProperty: self
SortFunction>>onProperty: aValuable ^SortByPropertyFunction sortProperty: aValuable with: self
What do you think?
Nicolas