preparing for const, final, and invariant

Walter Bright newshound1 at digitalmars.com
Sun May 20 21:00:33 PDT 2007


Derek Parnell wrote:
> What about 'const ref' meaning that a reference is being passed and that
> reference is constant but not the data being referred to...?
> 
>  class C { int x; }
>  void foo(const ref C c)
>  {
>       c.x = 3; // okay
>       c = new C; // fail
>  }

The trouble is that ref adds an extra level of indirection, and it would 
be confusing to say that in this case it didn't.

Another option is to reuse 'inout' to mean 'mutable', since 'inout' is 
replaced by 'ref'.



More information about the Digitalmars-d-announce mailing list