Whitespace

JPDev@programming.dev to Programmer Humor@programming.dev – 288 points –
58

You are viewing a single comment

You would think so, but int* a, b is actually eqivalent to int* a; int b, so the asterisk actually does go with the name. Writing int* a, *b is inconsistent, so int *a, *b is the way to go.

Yeah, and I'd say that's a design flaw of the language as it is unintuitive behaviour.

When people say “pointers are hard”, they mean “I have no idea where the star goes and now an ampersand is also implicated”.

That's the part where you give up and randomly shove/unshove symbols in until the code works.

While technically true, that's also one of the worst 'features' of the language and I personally consider it a bug in the language. Use two lines and make it clear and correct.

Don't declare more than 1 pointer per line. This resolves that, badly.

This is true in C, but not in D.