const debacle

Jason House jason.james.house at gmail.com
Fri Mar 21 20:36:30 PDT 2008


Maybe I'm not thinking straight, but wouldn't use of the return keyword in a function imply const access inside the function? The code must work if the input argument is const or not...


Walter Bright Wrote:

> Steven Schveighoffer wrote:
> > So your answer essentially is, there is no way to specify that the function 
> > will not modify the parameter but returns the same type passed in?
> 
> Right.
> 
> > Which means there is no check by the compiler to guarantee that source is 
> > not modified (unless T is const), and basically, the coder has to rely on 
> > the documentation to determine whether source will remain intact?  I think 
> > this degrades the benefits of const in this context.
> 
> There's been some discussion about this, but no good resolution. (C++ 
> has the same issue, btw.)




More information about the Digitalmars-d mailing list