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

> In my experience the compiler is pretty good at figuring out what is constant so adding const is more documentation for humans,

In the same TU, sure. But across TU boundaries the compiler really can't figure out what should be const and what should not, so `const` in parameter or return values allows the compiler to tell the human "You are attempting to make a modification to a value that some other TU put into RO memory.", or issue similar diagnostics.



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

Search: