var.init change

Chris Miller chris at dprogramming.com
Wed Sep 5 14:49:14 PDT 2007


On Wed, 05 Sep 2007 16:54:33 -0400, Robert Fraser  
<fraserofthenight at gmail.com> wrote:

> Any chance of getting the old behavior back as a different property? For  
> example:
>
> int x = 42;
> assert(int.init == 0);
> assert(x.init == 0);
> assert(x.starting == 42);
>
> For what it's worth, I agree that the new .init does increase  
> inconsistency, but the old behavior had its uses, so it's a shame it  
> went away forever.

Other ideas:
    x.varinit
    x.thisinit
    x.iinit (instance init)
    x.decl (declaration)
    x.declvalue
    x.firstvalue
    x.myinit


Another idea, the -v1 switch could make var.init an error (but keep  
Type.init as it is the same) as back then it meant the variable's  
initializer. If you have code with the old .init use, compile with -v1 to  
catch the issues.

Either way, I still would like something that represents the variable's  
initializer if it is constant. Without it, even if I catch all my .init  
issues, I'll have to write a bunch of constants and replace throughout the  
code.



More information about the Digitalmars-d mailing list