idiomatic D: what to use instead of pointers in constructing a tree data structure?

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 14 11:43:17 PST 2015


On Wednesday, 14 January 2015 at 19:36:44 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
> Moral of the story: don't have struct fields that point to the 
> struct
> itself. This is almost always a bad idea. Structs have value 
> semantics,
> and the implicit copying around will almost certainly break any
> self-referencing pointers, which leads to dangling pointers, 
> good
> friends of memory corruption, et al. :-P

If it actually had value semantics you would not be allowed to 
take the address of it... :-P


More information about the Digitalmars-d-learn mailing list