Ok I will allocate some time to produce a booklet on ston :).

S. 


On 30 Jun 2020, at 23:05, Sven Van Caekenberghe <sven@stfx.eu> wrote:

Hi Stef,

With the following commit https://github.com/svenvc/ston/commit/3565d388172b76c180454575d4c2f71019f130c4

there is now basic support for SortCollections using SortFunctions.

All of the following can now be serialised and materialised by STON (see #testSortedCollections):

SortedCollection new.
SortedCollection new: 0.

#(5 3 7 2 1 4 10 9 8 6) asSortedCollection.

#(5 3 7 2 1 4 10 9 8 6) asSortedCollection: #yourself ascending.
#(5 3 7 2 1 4 10 9 8 6) asSortedCollection: #yourself descending.

#('****' '*' '*****' '**' '***') asSortedCollection: #size ascending.
#('****' '*' '*****' '**' '***') asSortedCollection: #size descending.

#(5 3 7 2 1 4 10 nil 9 8 6) asSortedCollection: #yourself ascending undefinedFirst.
#(5 3 7 2 1 4 10 nil 9 8 6) asSortedCollection: #yourself ascending reversed undefinedLast.

I think this trick covers a large set of SortedCollection use cases avoiding blocks by using SortFunctions.

This technique could also be used to replace other block usages elsewhere.

To answer your original question: yes we could add this to the documentation (although right now it is very new and unproven).

Regards,

Sven

On 28 Jun 2020, at 12:25, St��phane Ducasse <stephane.ducasse@inria.fr> wrote:



On 27 Jun 2020, at 16:58, Sven Van Caekenberghe <sven@stfx.eu> wrote:

Hi Russ,

The limitation of STON not being capable of serialising a block closure still stands and will probably not change very soon (it open up the whole language to be written out).

You can work around this though, with sort functions for example.

Here is an example:

{ 1->#one. 3->#three. 2->#two } sorted: (STON fromString: (STON toStringPretty: #key ascending)).

SortFunctions are really cool BTW (they can handles nil values elegantly).

Sven

Sven do you think that we should have a little section on this question in STON chapter.

S



--------------------------------------------
St��phane Ducasse
03 59 35 87 52
Assistant: Aurore Dalle 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, B��t.A, Park Plaza
Villeneuve d'Ascq 59650
France