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

* is a right-to-left associative operator #93

Closed
wants to merge 1 commit into from
Closed

* is a right-to-left associative operator #93

wants to merge 1 commit into from

Conversation

Coeur
Copy link

@Coeur Coeur commented Feb 19, 2014

In C and Objective-C, the operator * is a right-to-left associative operator:
https://en.wikipedia.org/wiki/Operators_in_C_and_C++#Operator_precedence

Which means it should be next to the right element, not the left element. And easy way to understand the issue:

char* a, b;

As * is a right-to-left associative operator, * applies to a, not char and we have:

  • a is an array of char
  • b is a char, not an array of char

To make it easier to apprehend, and to avoid mistakes when we want twice the same type, we should have:

char *a, *b;

Right-to-left associativity for * is the same as the one for !. And you don't write:

BOOL p =! q;

You write:

BOOL p = !q;

@agrieve
Copy link
Contributor

agrieve commented Feb 19, 2014

Thanks for having a look at our code, but we make a conscious decision to avoid style-related changes.

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

Successfully merging this pull request may close these issues.

2 participants