[Pharo-dev] about SortFunctions

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun Nov 5 05:28:10 EST 2017


2017-11-05 9:52 GMT+01:00 Stephane Ducasse <stepharo.self at 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20171105/15d16065/attachment-0002.html>


More information about the Pharo-dev mailing list