this post was submitted on 02 Feb 2024
285 points (96.7% liked)

Programmer Humor

19735 readers
785 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 82 points 10 months ago* (last edited 10 months ago) (6 children)

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.

[–] [email protected] 53 points 10 months ago

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

[–] [email protected] 35 points 10 months ago (1 children)

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

[–] T156 23 points 10 months ago (1 children)

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

[–] [email protected] 5 points 10 months ago

I've definitely never been guilty of this. /s

[–] [email protected] 23 points 10 months ago

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.

[–] [email protected] 13 points 10 months ago

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

[–] [email protected] 8 points 10 months ago

Alright, I'll never, ever write something this way now. Good to know.

[–] [email protected] 3 points 10 months ago

This is true in C, but not in D.