From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: <571511e7dddc323d94a6da81f35ba899@terzarima.net> References: <571511e7dddc323d94a6da81f35ba899@terzarima.net> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <874BB1C1-E509-472F-8DBD-9EC0575E2F9B@telus.net> Content-Transfer-Encoding: 7bit From: Paul Lalonde Subject: Re: [9fans] const Date: Wed, 7 Dec 2005 13:22:28 -0800 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: be1173b6-ead0-11e9-9d60-3106f5b1d025 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