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

Prefer returning bool/enum values over integers #1

Open
jhauberg opened this issue Sep 7, 2018 · 0 comments
Open

Prefer returning bool/enum values over integers #1

jhauberg opened this issue Sep 7, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@jhauberg
Copy link
Owner

jhauberg commented Sep 7, 2018

In the most basic cases, where a function is indeed only either successful or not, bool should always be used.

In cases where a non-successful result carries more information, an enum should be used. For example, lxt_parse, which can hit several different failures, should return which exact failure it hit (e.g. max containers, entries etc.).

It might even be worthwhile to go further than just simple enums and instead return stateful information so that the library can report exactly where and why something went wrong; e.g. parsing errors at line and column numbers. But that is probably better fit as a separate issue.

@jhauberg jhauberg added the enhancement New feature or request label Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant