Proposal for scoped const contracts

Walter Bright newshound1 at digitalmars.com
Mon Mar 24 12:01:52 PDT 2008


Steven Schveighoffer wrote:
> It is basically an idea for scoped const.  The main goal is so that one can 
> specify that a function does not modify an argument without affecting the 
> constness of the input.

I understand what you're asking for, and it does solve some issues. It's 
almost exactly the same as the "return" qualifier I'd bandied about last 
summer:

	T foo(return T t);

where the 'constness' of the argument for t is transmitted to foo's 
return type at the point of call of foo(), not at the point of 
definition of foo. This implies, of course, that foo cannot change t itself.

For me, the question is is solving these issues a large enough problem 
that justifies adding a rather confusing new variation on const?



More information about the Digitalmars-d mailing list