rust-embedded-community / serde-json-core

`serde-json` for `no_std` programs
Apache License 2.0
161 stars 59 forks source link

Proposal: feature flag for float support #28

Closed webmaster128 closed 4 years ago

webmaster128 commented 4 years ago

Floating point operations are known to be problematic when it comes to determinism. In the blockchain space, we tend to avoid them (and rather use decimal types). At https://github.com/CosmWasm/serde-json-wasm we maintain a fork of this repo that is specialized on WebAssembly and blockchain. I think it would be cool to be able to keep the repos in sync as much as possible.

Since we check all the WebAssembly instructions in the blockchain, they need to be non-existent in the compilation result (no matter if used or not). Would you accept a PR adding a floats feature flag (turned on by default)? This is for sure not a general purpose request. But maybe it is interesting for other users as well that either worry about code size or determinism.

webmaster128 commented 4 years ago

Thinking about this more, it turns out both projects have too different goals to invest in compatibility.

serde-json-wasm's goals:

serde-json-wasm's non-goals:

songtianyi commented 1 year ago

Very thoughtful proposal, it should be reconsidered.