Proposal for scoped const contracts

Roberto Mariottini rmariottini at mail.com
Wed Mar 26 03:48:43 PDT 2008


Walter Bright wrote:
> 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?

If I understand correctly this could be achieved with the plain old 
'final' keyword. Am I right?

Ciao
-- 
Roberto Mariottini, http://www.mariottini.net/roberto/
SuperbCalc, a free tape calculator: 
http://www.mariottini.net/roberto/superbcalc/



More information about the Digitalmars-d mailing list