4 ms·
D's destructors are not deterministic, IIRC. > using unsafe for graphs or dealing with use-after-free array indexes for the alternative workaround, unsafe Drop
by dpc_pw 7y ago
D's destructors are not deterministic, IIRC.
> using unsafe for graphs or dealing with use-after-free array indexes for the alternative workaround, unsafe Drop implementations, doesn't look hassle free to me.
Valid points, but these are rare problems in idiomatic Rust.
Specifically avoiding graphs by structuring code into a tree of ownership, has greatly improved architecture of my programs, to the point that I just do it like this in all programming languages I use.
Rust made me realize how many problems objects carelessly cross-referencing each other (especially in OOP) - "because there's a GC, so why not" create.
Similar with array of indexes - great improvement both in usability and reliability. At least all use after-free in that case is checked and fails deterministicly. It makes my data with graph-like, or relationship properties resemble relational database.
For problems with lifetimes in destruction all I needed so far is https://crates.io/crates/dangerous_option https://crates.io/crates/dangerous_option . I actually wish it was part of language (a nullable types, panicking at runtime).
- pjmlp 7y ago> D's destructors are not deterministic, IIRC. Yes they are, they get called at the end of scope. > Valid points, but these are rare problems in idiomatic Rust. Being rare doesn't mean they aren't there, and anyone trying to write UI related code will deal with them on regular basis.
- dpc_pw 7y agohttps://forum.dlang.org/thread/tsfgbmakzcrxwqreheiq@forum.dlang.org?page=3 https://forum.dlang.org/thread/tsfgbmakzcrxwqreheiq@forum.dl... Can you clarify, what am I misunderstanding here? In couple of places online I've found that you can't depend on dtor being called.