-
Notifications
You must be signed in to change notification settings - Fork 13
Add compile-time support for reading/writing simple streams (fixes #77) #82
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
Conversation
|
|
||
| template writeText*(s: OutputStream, val: auto) = | ||
| write s, $val | ||
| when val is SomeFloat: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not leave it as an overload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overload doesn't work in Nim 2.0.16 due to a Nim regression nim-lang/Nim#25166
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
welcome to nim development ;) we note bugs in the code with # TODO https://github.com/nim-lang/Nim/issues/25166 so we can track them down later, at the point where they're relevant
|
float roundtrip format lgtm - indeed, better to have it consistent and above all, round-trippable for the intended use case. |
|
hm, also, can replace the custom code in toml-serialization now? |
Fixes #77
Changes:
writeTextfor floats so the output is the same across nim targets and versions. However, for float32 the output should now be the same as for float64. Nim +2.2.2 made this the default. The alternative is to keep the current behavior, but the result differs for the VM and across Nim versions, for example 1.23 is printed as1.230000019073486at runtime (sprintf) in Nim < 2.2.2,1.23in Nim >= 2.2.2, and1.2300000190734863(note the extra digit) at comptime (aftercast[float32](cast[uint32](val))the float32 val).I checked json and cbor serializers passes most tests at comptime with these changes, the few that fail are unrelated to faststreams.
Tested for regressions here: