Hacker News new | past | comments | ask | show | jobs | submit login

It is entirely appropriate for a function which lexically analyzes a buffer in memory in order to match an integer to be able to tell you where that integer ends.



i think thats a reasonable opinion in the context of say, language implementation.

for the relatively simple case of parsing cli arguments i would want an equally simple api. "is this string a valid representation of a number?" and "what number does this string represent?" should be separate apis.

even in language implementation, i'd want the identification of number tokens to be separate from the parsing of those number tokens. i would then have another, separate api for "where does the first number end in this string?" which would probably more likely be "return to me the next substring from this string that represents a number"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: