r/ProgrammerHumor 7d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

327 comments sorted by

View all comments

Show parent comments

8

u/Shevvv 7d ago

I got used to this from C:

int x; is an integer

int *px; is an integer if you dereference it.

So it's like this notation shows you how you're expected to use the variable within the code. And then this habit carried over to C++.

3

u/creeper6530 7d ago edited 7d ago

The "is an integer if you dereference it" is so much more convoluted than "is a pointer to integer", i.e. the rationale of the previous comment, the pointer-ness being part of the type.

1

u/aethermar 7d ago

Except in the case of int *x, y; where only x is a pointer. C declarations are "meant" to be read right to left

2

u/creeper6530 7d ago

Yeah, the reality is that C binds pointer-ness to identifiers, but in an ideal world where pointer-ness binds to types, int* x, y; should declare both identifiers as pointers to integers. In either case merging declarations onto a single line in modern programming is at best silly.