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

Missing Example in C Naming Conventions #15

Open
PaulTreitel opened this issue Sep 13, 2022 · 1 comment
Open

Missing Example in C Naming Conventions #15

PaulTreitel opened this issue Sep 13, 2022 · 1 comment

Comments

@PaulTreitel
Copy link

The second-to-last paragraph in the C Style Guide Naming Conventions refers to missing examples of why loop variables shouldn't always be one letter. An adaptation of the Python examples might be:

No:

for {int x = 0; x < data_len; x++) {
    // ...
    // 10 lines of code
    // ...
    float y = m / 60;
    // ...
    // 50 lines of code
    // ...
    data[x] += y
}

Yes:

for {int student_index = 0; x < data_len; x++) {
    // ...
    // 10 lines of code
    // ...
    float hours_worked = m / 60;
    // ...
    // 50 lines of code
    // ...
    data[student_index] += hours_worked;
}
@borjasotomayor
Copy link
Member

Thanks, I've added the missing example (largely the one above, with some minor tweaks). I've also reformatted that section, as it was hard to tell that the section includes a list of (not entirely related) naming conventions.

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