Public outcry against new .init behaviour

Xinok xnknet at gmail.com
Mon Jul 2 18:54:29 PDT 2007


Vladimir Panteleev wrote:
> On Mon, 02 Jul 2007 21:07:48 +0300, Robert Fraser <fraserofthenight at gmail.com> wrote:
> 
>> I agree.... But the change should only be introduced to the 2.x branch... Breaking changes have no place in the stable branch.
>>
>> Maybe you could add a different property that can get the old behavior for variables, too...?
> 
> I concur - how about a new .default property? It's pretty clear that it resolves to the default value for this type (x.default==X.default), unlike .init, which is the value this variable is initialised to (and is the same as .default for types) :)
> 
> Also, agreed that the old behavior ought to be reverted for 1.x and this would only go to 2.x.
> 

I think that's the best solution, revert .init to it's old behavior, and 
add a new property to reflect it's new behavior.
Of course, .default probably couldn't be used since that's a keyword.

I'm only using "typeinit" as an example, I'm sure there's a better word 
that could be used. typeinit would simply be an alias for typeof(t).init

typedef int T = 3;
T v1 = 5; // v1.init == 5, v1.typeinit == 3
T v2; // v1.init == 3, v1.typeinit == 3



More information about the Digitalmars-d mailing list