Const correctness revisited (proposal)

Walter Bright newshound1 at digitalmars.com
Mon Mar 24 12:29:05 PDT 2008


Oliver Dathe wrote:
> That's right what pushed me to think about tail constness regarding 
> parameters. You could have the cont-ness contract without touching the 
> type.
> 
>   T[] f(T[] t const) {
>     return t;
>   }
> 
> It is a transient const-ness not a reflexive. It does not creep into 
> types or out of the function. It is transitive in the way that it has to 
> creep down subsequent calls within f() to functions that take t as 
> paramter. That's all pretty sound isn't it? It as well avoids /polution/ 
> of types at the same time.

That would be of very limited utility because I could not pass a 
const(T)[] array to the function. It's weird to have a function that 
doesn't modify its parameters where one could not pass const data to.



More information about the Digitalmars-d mailing list