Stepping back and looking at constness from another angle.

Denton Cockburn diboss at hotmail.com
Wed Jun 6 23:38:17 PDT 2007


On Thu, 07 Jun 2007 16:25:21 +1000, Reiner Pope wrote:

> Another problem with const by default came to mind. Consider the
> following code, with const-not-by-default:
> 
> void foo( ref const(char)[] c)
> {
>      c = c[1..$];
> }
> 
> I would hate to see this in const-by-default, which would try to wrap a
> const( ) around the whole type. To counter that, you would probably have
> to write some mess like
> 
> void foo ( mutable( ref const(char)[] ) c ) {
>      c = c[1..$];
> }
> 
>    -- Reiner

Again, I'm also trying to understand this, knowing that things change a 
lot over the course of the discussion. That being said, I thought the 
current position is that by adding any other qualifier, such as ref, 
const/scope/final is no longer automatically applied.



More information about the Digitalmars-d mailing list