Proposal: feature flag for float support
webmaster128 opened this issue · 2 comments
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.
Thinking about this more, it turns out both projects have too different goals to invest in compatibility.
serde-json-wasm's goals:
- deterministic serialization (which makes things like maps non-trivial)
serde-json-wasm's non-goals:
- no_std compatibility
- heaplessness
Very thoughtful proposal, it should be reconsidered.