July 17, 2013 Re: Feature idea: .userinit property (or trait) to retrieve the initializer of a variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | 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... |
Copyright © 1999-2021 by the D Language Foundation