On 7-Dec-05, at 1:07 PM, Charles Forsyth wrote:
if you followed the earlier links you'll see one of the classic
examples
of it being fairly odd as an interface constraint:
char* strchr(const char* x, int y)
I call this an interface bug: really, it should return a const char
*, not a char *. For the case where the input string was not const
the user can obviously strip the constness from the return value.
It is a clear example of trying to make a piece of notation do two
things. One is to say that the function does not modify its
paramter, which is of clear benefit to the optimizer when calling the
function. The second is to say that the data pointed to should not
be changed, which is a semantic constraint for the programmer.
Ugly.
Paul