asc-community / AngouriMath

New open-source cross-platform symbolic algebra library for C# and F#. Can be used for both production and research purposes.
https://am.angouri.org
MIT License
782 stars 74 forks source link

Make Entity serializable #323

Open WhiteBlackGoose opened 3 years ago

WhiteBlackGoose commented 3 years ago

And make FieldCache non-serializable

Happypig375 commented 3 years ago

Not worth it. https://github.com/dotnet/designs/blob/main/accepted/2020/better-obsoletion/binaryformatter-obsoletion.md

WhiteBlackGoose commented 3 years ago

@Happypig375 the fact that Entity will be serializable doesn't imply by default what exact framework or technique we will use for it. Probably, it will be similar to ToString and return a base64 format. And a MathS.Deserialize will create an Entity back from a serialized one.

That's my thoughts, but there should be serialization, so that you could save your formulas, or send somewhere, etc. Remember, that we don't guarantee a.ToString().ToEntity() be parsable and equal to a.

Happypig375 commented 3 years ago

So why not an existing and widespread format like JSON, XML, YML, etc.?

Happypig375 commented 3 years ago

Or not just Parse/ToString?

WhiteBlackGoose commented 3 years ago

Maybe we will take JSON, I don't know. I just thought that maybe we want a compressed and fast format

Happypig375 commented 3 years ago

Just Stringize/Parse should be compressed enough, right? I don't know about fast though, but shouldn't be much slower.

WhiteBlackGoose commented 3 years ago

Like I said, a.ToString().ToEntity() != a. Say, is 1 + 2 + 3 same as (1 + 2) + 3 or 1 + (2 + 3)? For this one we have ExplicitOutput setting, but in general, it might be not parsable back. Also, we need to check how slower it is to parse than to convert from a binary expression.