final invariant request = disallow meaningless attributes

Jason House jason.james.house at gmail.com
Sun Jun 24 11:20:45 PDT 2007


Ary Manzana wrote:
> I totally agree with this.
> 
> If one of the purposes of the new modifiers are to provide better 
> documenation from within the language itself, then if the compiler 
> doesn't warn you if you write
> 
> const invariant int x = 3;
> 
> then it's counterproductive. Against the meaning of "provide better 
> documentation".

I think some exception is needed for generic programming.  Redundancy 
with a templated parameter type should be allowed.

class A;

class(T) B{
   T x;
   const T y;
   invariant T z;
}

B!(A) x;
B!(const A) y;
B!(invariant A) z;


Which instances of B, if any, should result in a compiler error?



More information about the Digitalmars-d mailing list