Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Exactly: if 'int const * ' were common, it would be relatively clear that const goes after the type of the thing that is const - but the overwhelming use of the alternate form, 'const int *', makes it more confusing what to do.


const int * - pointer to const int

I see this is as

(const int)* foo;

which is the same as

(int const)* foo;

And people prefer

const int foo;

over

int const foo;

So it all makes sense in terms of the grammar. Admittedly, it can be difficult to remember, but pointers and const correctness are complicated and combining them is going to be complicated to write out no matter what grammar you use. Even if the grammar was restricted, it's difficult to remember this type of thing and if you encountered such code in the wild and had any doubts about its semantics then you would look it up on Google before modifying it (right?)




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: