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

Revisit coding standards #7371

Open
ThanHenderson opened this issue Jun 11, 2024 · 1 comment
Open

Revisit coding standards #7371

ThanHenderson opened this issue Jun 11, 2024 · 1 comment

Comments

@ThanHenderson
Copy link
Contributor

ThanHenderson commented Jun 11, 2024

Given the updated supported-feature list for C++11 (#7369) (edit: still updating), we should revisit the coding standards (https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md) and add in guidelines and standards for newer features e.g. nullptr and lambdas.

While there, it may be beneficial to audit the existing standard -- it hasn't been meaningfully revisited in 8 years (for better or worse) -- and see how these newer features could change the current guidelines.

Moreover, the standard for return states that multiple return points should be avoided. Despite the standard attempting to back this statement up with [multiple return points] can make the flow of code more difficult to understand, I'd argue the opposite; avoiding multiple return points often leads to unnecessary complexity in control flow and, in the presence of goto, complexity in variable declarations and brittleness that is counter to modern C++.

In particular, procedures that require manual cleanup are often riddled with goto done and deep nesting. With the support of lambdas, an alternative approach could be to define lambdas with cleanup code and have early returns accompanied by calls to the cleanup lambda, leading to flatter, more understandable procedures.

@dsouzai
Copy link
Contributor

dsouzai commented Jun 12, 2024

@0xdaryl maybe this could be discussed in the next architecture meeting?

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