Conversation
|
request yet another clarification your code with or I don't see something important in this solution? |
|
It's theoretically possible for a |
|
okey, but why don't return |
|
Mainly because the |
I try to adopt my sbin library and don't understand one moment: if I try serialize sumtype value with const and not const payload I can't pass simple example: /+ dub.sdl:
dependency "sumtype" version="1.1.0"
+/
import std.stdio;
import sumtype;
alias S1 = SumType!(const(int[]), int[]);
void printConst(in S1 v) { writeln(v.typeIndex); }
void printRef(ref S1 v) { writeln(v.typeIndex); }
void main()
{
int[] value = [1,2,3];
auto s = S1(value);
printConst(s); // 0
printRef(s); // 1
}Can you explane how to serialize sumtype value and deserialize after and get the same payload? Serialization function must get const value because it must not change anything in value, deserialization function get ref. |
|
If you serialize from a mutable If you serialize from a |
You don't understand, I serialize mutable object, but pass it into serializer with Why I have interest with [de]serialization? Because [de]serialization is place where algebraic types are most useful in D, if no need serialize simple data objects and/or they more complicated, then classes can be used (classic OOP). For [de]serialization simple data getting raw information about stored data is very useful. In this case it's tag type ( |
|
Please calm down. The kind of accusatory language you are using is entirely uncalled for, and you will be blocked from commenting here if you use it again. The current version of Either way, there is a tradeoff being made. You have made a reasonable argument that the tradeoff chosen by the current version is the wrong one, and should be changed, so I have created #58 to address this. |
I didn't mean to sound rude. I'm sorry. Serialization and deserialization is general case (to json, yml or xml for example). Can you please show example how to serialize sumtype object and deserialize it to original state (for example to and from abstract text representation)? By now I don't see easy (short) way, it requires many non trivial or not universal code (synchronize methods of getting tag, tag type, tag limits, type by tag in serialization and deserialization parts, when it simply hidden by |
Fixes #56.