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

Create a naming convention for iterator variables #313

Open
Adda0 opened this issue Aug 28, 2023 · 0 comments
Open

Create a naming convention for iterator variables #313

Adda0 opened this issue Aug 28, 2023 · 0 comments
Labels
For:library The issue is related to library (c++ implementation) Priority:low Work on this only when there is nothing else to do. Type:discussion A discussion of some particular topic in wider audience

Comments

@Adda0
Copy link
Collaborator

Adda0 commented Aug 28, 2023

It was decided that we will name iterator variables as <the_name_of_the_object_we_get_by_dereferencing_the_iterator>_it. We can slowly begin renaming all existing iterator variables to adhere to this convention.

Const variables for iterators returned by begin() and end() methods should be named <the_name_of_the_object_we_get_by_dereferencing_the_iterator>_begin and <the_name_of_the_object_we_get_by_dereferencing_the_iterator>_end, respectively.

For example, for const iterator over StatePost, we get the following variable name:

StatePost::const_iterator symbol_post_it = nfa.delta.state_post(4).begin();
StatePost::const_iterator next_symbol_post_it = ++symbol_post_it;
const StatePost::const_iterator symbol_post_begin = nfa.delta.state_post(4).begin();
assert(next_symbol_post_it != symbol_post_begin);

When using the iterator over a small block of code (e.g., at most 3-line for loop), one can use just it and similar without having to specify the name of the object at all.

Does anyone have any further comments or suggestions?

@Adda0 Adda0 added For:library The issue is related to library (c++ implementation) Type:discussion A discussion of some particular topic in wider audience Priority:low Work on this only when there is nothing else to do. labels Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For:library The issue is related to library (c++ implementation) Priority:low Work on this only when there is nothing else to do. Type:discussion A discussion of some particular topic in wider audience
Projects
None yet
Development

No branches or pull requests

1 participant