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

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 14 12:21:07 PST 2015


On Wed, Jan 14, 2015 at 07:43:17PM +0000, via Digitalmars-d-learn wrote:
> 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

Huh? ints have value semantics, yet you can take the address of a local
int variable. What's your point?


T

-- 
Not all rumours are as misleading as this one.


More information about the Digitalmars-d-learn mailing list