-
Notifications
You must be signed in to change notification settings - Fork 0
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
add fmtFloat
to stdlib
#766
Comments
That was my idea on the original PR too, but got chopped off as usual. 🤷 |
the fact that there was so many review comments and commits in the PR (because of failing edge cases) played a role IMO in the closing of that PR. But regardless, the feature is useful and (as you discovered yourself) is tricky to implement correctly, which makes it a great candidate for stdlib; we should address the concerns raised in the closing comments regarding API though. |
My first commit was fast and easy to understand, The problem is that adds more and more defensive programming, |
I'm not saying it's an easy problem; the API needs to satisfy both:
decisions to make
APIit should be additive (analog to addFloat), which is the most composable/efficient, can be used in conjunction with type OptFloatFmt = object
sep: char ...
type OptFloatParse = object
sep: char ...
proc addFloatCustom*(result: var string, a: SomeFloat, opt = initOptFloatFmt())
proc parseCustom*(ret: var SomeFloat, s: openArray[char], opt = initOptFloatParse()): int
# returns nb of chars parsed in `s` note#741 could be used to define packed object (more efficient + syntax sugar) instead of OptFloatFmt, OptFloatParse |
I should live there IMHO. |
possibly |
links
implementation
https://forum.nim-lang.org/t/8162#52480
The text was updated successfully, but these errors were encountered: