Skip to content

Use descriptive enums instead of Boolean parameters #1854

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

Open
tautschnig opened this issue Feb 16, 2018 · 1 comment
Open

Use descriptive enums instead of Boolean parameters #1854

tautschnig opened this issue Feb 16, 2018 · 1 comment

Comments

@tautschnig
Copy link
Collaborator

The semantics of true or false are often hard to understand without extensive context. Using enums (with just two values, but descriptive identifiers) may be a better route.

@hannes-steffenhagen-diffblue
Copy link
Contributor

hannes-steffenhagen-diffblue commented Feb 16, 2018

As an example for this, simplify_expr returns true when the expression was simplified and false when it wasn't. If you see code like if(simplify_expr(expr)) you need to know this to read the code; If it was something like if(simplify_expr(expr) == Simplify::ChangedExpression) it'd be easier to discern the meaning (this isn't a parameter in this case, but basically the same logic applies).

It's certainly worth having a discussion about the places where we use "meaningful" booleans like this (i.e. where a boolean is used as a generic two-value thing instead of an actual True/False thing).

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

No branches or pull requests

2 participants