const debacle

BCS ao at pathlink.com
Fri Mar 21 12:33:19 PDT 2008


Reply to Steven,

> I remember that idea.  I'm concerned however that in this mode, the
> compiler will not check the function itself for const-correctness
> (i.e. ensure it doesn't modify the input) because the argument will
> not be const.  See my reply to Walter for my example.  I want a way to
> specify "the function's return type has the same constness as one of
> it's arguments, and it promises not to modify that argument, and the
> compiler made sure of that."
> 
> -Steve
> 

it should be possible to have the compiler work the way you want. The function 
would be built assuming some level of constness and then, at the calling 
site the arg would be checked to see if it is no more restrictive. If so, 
then the call is allowed and the return type is generated from the arg's. 
(all at compile time of course)





More information about the Digitalmars-d mailing list