> On 17 May 2017, at 15:47, Cyril Ferlicot D. <cyril.ferli...@gmail.com> wrote:
> 
> On 17/05/2017 15:17, Sven Van Caekenberghe wrote:
>> 
>> 
>> OK.
>> 
>> But don't go too far in writing actual code. I want to understand the use 
>> case at a high level (like how you started), then I can try to find how/if 
>> STON can do what you want. Right now, you are already too deep into a 
>> possible solution.
>> 
>> 
> 
> If I have to give a really simple use case.
> 
> Imagine an invoice.
> 
> The invoice has the name of the customer and the currency used as a class.
> 
> During the export of the invoice you do not want to export the currency
> as a class but as a String.
> 
> So if I have an Invoice instance like this:
> 
> username: 'user'
> currency: Currency[Euro]
> 
> I want to transform the currency to a string during the export. (and
> keep the username as strings).
> 
> Result:
> 
> Invoice {
>       #username : 'user',
>       #currency : 'eur'
> }
> 
> Instead of:
> 
> Invoice {
>       #username : 'user',
>       #currency : Currency {
>                               #unit: 'Euro'
>                       }
> }
> 
> Then during the import I want to transform the currency into a class
> again. (For example `Currency fromAbbreviation: stonInput`).

OK, that is an understandable example. 

But why exactly do you want Currency to be serialised differently ? You don't 
want too many instances ? You want all instances to be #== ? Is Currency too 
big ? You want to allow humans to edit the STON file ? What ? Why ?

You can easily make it Currency['Euro'] or even Currency[#Euro] like it is 
already done for a number of built-in classes.

The last example that I gave solved the 'too many instances', make them #== 
issue.

If it is size, that got covered too, but you must solve the problem of how the 
receiving end will resolve the reference then.

But since that is all no good, there must still be another requirement.

> -- 
> Cyril Ferlicot
> https://ferlicot.fr
> 
> http://www.synectique.eu
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
> 


Reply via email to