-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Always serialize NaN without sign #640
Conversation
There are two layers here
I think I'd like to start by exercising caution and only doing this in the Thoughts? |
It's already the case that users don't control exactly how toml files look, as |
TOML also doesn't guarantee table order but we want to preserve that an allow control over it. I'd like to, over time, offer more options for users to control how things are rendered. |
So even if you want to give users the ability to control how a NaN is printed, I'd encourage you to do it in some other way than inferring it from the sign bit on And in that case, then the ability to serialize "-nan" wants a new API, and it seems prudent to wait until someone comes up with a real-world use case for it. |
@sunfishcode my suggestion was that The area we still respect the sign bit is if you are directly using |
Currently The sign bits of user-supplied |
Yes, The remaining question is what is correct for a low level API that is meant to control as much about the formatted output as is reasonable (weighted against lack of API designs, time availability, and performance constraints). To put this into context, most developers using these packages will be relying on #643. |
The sign bit of an If you wish to give users control over how NaNs are formatted, I suggest adding an explicit API mechanism, rather than implicitly inferring it. That avoids unintentionally propagating nondeterminism. Such a mechanism would also be needed to support "+nan". |
As nothing new is being said, I'm going to go ahead and close this for now. We can revisit this in the future if needed. |
In all likelihood, the sign of NaNs is not meaningful in the user's program. rust-lang/rfcs#3514 (comment): "by and large nobody cares about the sign of a NaN". It would usually just be surprising and undesirable for
-nan
to appear in output serialized by this crate, when the sign of the NaN was not intentionally controlled by the caller, or may even be nondeterministic if it comes from arithmetic operations or a cast.In toml-lang/toml#506 (comment) it sounds like the motivation for TOML supporting
-nan
was a Robustness Principle "be liberal in what you accept from others" without the intention that TOML emitters would ever produce it.This crate will continue to deserialize
-nan
as a negative NaN as implemented by #637.