Skip to content
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

Factor Error and Expected boilerplate return-macros #92054

Open
mtrofin opened this issue May 14, 2024 · 1 comment
Open

Factor Error and Expected boilerplate return-macros #92054

mtrofin opened this issue May 14, 2024 · 1 comment

Comments

@mtrofin
Copy link
Member

mtrofin commented May 14, 2024

Examples: RETURN_IF_ERROR and ASSIGN_OR_RETURN or these with a slightly different name.

The idea is to place them in Error.h

@mtrofin
Copy link
Member Author

mtrofin commented May 14, 2024

FWIW, it may be more tricky than it seems. The Error case is straightforward, the Expect<T> isn't. In the OutputSizeLimitTest.cpp example, the goal is to assign Var to *Expect, while in the ResourceScriptParser.cpp example, Var gets assigned Expect. Then, here it gets more interesting, with references and const references.

Maybe we end up with a few macros, but then again, maybe having these macros n-plicated isn't so bad afterall.

Also:

  • and there's also ErrorOr.
  • ASSIGN_OR_ERROR (and RETURN_IF_ERROR) is a very good name, it's also unfortunately taken by abseil. If these appear in a header, it will complicate codebases where llvm and abseil mix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant