digitalmars.D.learn - clear works better than it ought to considered i never defined it
- Vlad Levenfeld (9/9) Jul 27 2014 A weird thing happened:
- Mike (6/16) Jul 27 2014 I'm not sure, but is your code calling the runtime `clear`
- Vlad Levenfeld (2/2) Jul 27 2014 Yep, just checked in the debugger. So, that's actually a bad
A weird thing happened: I was building a dictionary struct which contains a custom array of values and a differently-typed custom array of keys. Both of them implicitly define "clear" by aliasing a backing array. The dictionary type doesn't have clear, though. And it doesn't alias anything. Yet when I call clear on it, not only does it work, but it clears both of the private contained arrays. I can't find any free clear function in Phobos. Not that I'm complaining, but... what's going on here?
Jul 27 2014
On Monday, 28 July 2014 at 06:27:44 UTC, Vlad Levenfeld wrote:A weird thing happened: I was building a dictionary struct which contains a custom array of values and a differently-typed custom array of keys. Both of them implicitly define "clear" by aliasing a backing array. The dictionary type doesn't have clear, though. And it doesn't alias anything. Yet when I call clear on it, not only does it work, but it clears both of the private contained arrays. I can't find any free clear function in Phobos. Not that I'm complaining, but... what's going on here?I'm not sure, but is your code calling the runtime `clear` method: https://github.com/D-Programming-Language/druntime/blob/master/src/object.di#L519 It has been marked for deprecation in the upcoming 2.066 release. Mike
Jul 27 2014
Yep, just checked in the debugger. So, that's actually a bad thing, then. Good thing its being deprecated!
Jul 27 2014