On Sat, May 31, 2014 at 2:59 AM, Stephen R. van den Berg srb@cuci.nl wrote:
Chris Angelico wrote:
So the question is, what does a 'const struct hash_table *' imply? Is
Strictly speaking it only says that the direct struct hash_table element this pointer is pointing at will not be modified in any way. If the struct contains other pointers, the things these pointers point at can be modified, but not if they point back into the current struct hash_table.
The C-standard doesn't say it (AFAIK), but it is good practice that if the struct is part of an array or linked list, none of the other array or linked list elements are being modified either.
I know what the C standard means, I was wondering what it meant in the context of Pike's data structures :) Does it make sense to declare this parameter as const and then tell the compiler that "hey, this bit over here isn't const", or is it better to mark it all as mutable?
Marking the entire argument as mutable doesn't add any warnings anywhere else, but that just means that nothing else is taking advantage of its constness in a way the compiler can recognize.
ChrisA