related to Make function paramaters immutable by default .
Is there even/now a way to express in the formal parameters of a function that the function should not / does not modify contents? I could think both C-type
type * const and
const type * could be useful in catching bugs in the function itself, beside the fact that it could help compiler optimizations.
I know that the ‘!’ is a convention to designate functions that modify memory being pointed to, but it’s just convention (and there may be multiple arguments).