[llvm] [libc] Add monadic functions to cpp::expected (PR #66523)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 22 16:26:49 PDT 2023


michaelrj-google wrote:

I'm still not sure that this is the best design for a string parser.

There are some steps that need to be executed conditionally. In your example, you always run the `consume_optional_prefix` step, which sets the base based on the prefix. It's an important step, but only relevant when the starting base is 0 or 16. For any other base, it's unnecessary, and as it's written right now it will always treat the base as if it's 0.

Additionally, there are some steps that may succeed before the final step. As an example, in string to float, there should be a step that checks for "inf" and "nan". If one of those special cases is found, it should return immediately, since no further parsing is necessary.

I'm certain that these specific problems could be fixed, but I'm worried that fixing them will create more complexity than it removes.

https://github.com/llvm/llvm-project/pull/66523


More information about the llvm-commits mailing list