Feature idea: .userinit property (or trait) to retrieve the initializer of a variable

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jul 17 15:41:20 PDT 2013


On Thu, Jul 18, 2013 at 12:33:20AM +0200, Vladimir Panteleev wrote:
> On Wednesday, 17 July 2013 at 11:28:18 UTC, Andrej Mitrovic wrote:
> >Anyway, I think the feature should be fairly easy to implement, but
> >would anyone else have a use for this?
> 
> At least once I wanted to reset a variable to its default value
> (which wasn't in a manifest constant).
> 
> Would it make sense to [ab]use the "default" keyword for this, to
> avoid introducing a new property which might collide with existing
> code?

How would you handle this case:

	int x = funcWithSideEffects();
	x = 123;
	x = x.default; // what is the value of x now?

?


T

-- 
Two wrongs don't make a right; but three rights do make a left...


More information about the Digitalmars-d mailing list