Hacker News new | ask | show | jobs
by jdbdndj 612 days ago
I don't see a foot gun, you just need to check if you have consumed the whole input. Which is the norm in nearly any streaming api
3 comments

I didn't see a foot gun either, but somehow my foot went missing.
I get that this is a super low level API, but yet, my expectation about an API that parses a buffer with length to a number and which has a specific enum for error cases as its return type would be that when asked to parse "9not a number" that I would get an error response and not a "the number you asked me to parse is 9 and everything went well" as the result.

The whole reason for returning a result enum would be so I don't forget to also check somewhere else whether something could possibly have gone wrong.

Especially when there is a specific result type.

But now you need a different API to compute where a number starts and end and that API must use exactly the same definition of number.
There could be an enum value for "read a partial number"
In what way is it streaming? It takes at least the entire numeric string as a string in memory, you can't stream in more data as needed