const debacle

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 24 10:06:04 PDT 2008


"Janice Caron" wrote
> On 24/03/2008, Bill Baxter wrote:
>> Steven Schveighoffer wrote:
>>  > I also want to be able to specify that the compiler should
>>  > complain if the function modifies the mutable input.
>>
>> I think that right there is basically the *only* think I really want out
>>  of a const system.  And even for that "best effort" is good enough for
>>  me.
>
> No less than three working solutions have been mentioned on this
> thread: a template solution, suggested by me; a solution using an
> explicit cast suggested by Daniel919; and the notion of returning
> indeces suggested by me. How many more working solutions do we need?
> This is a solved problem.

No, it is not a solved problem.  As a caller of a function, you still cannot 
rely on the compiler verifying that a function does not modify it's 
arguments for mutable arguments.  The only way to be sure is to read the 
source code yourself.  I'd much rather have the compiler do it.

-Steve 





More information about the Digitalmars-d mailing list