|
|
|
|
|
by derefr
3331 days ago
|
|
> They're inherently imperative; they don't return anything because they have no one to return it to. If your think of your whole program as being a wrapped in an implicit State monad, holding a POSIXProcessState (e.g. exit code, registered signal handlers, file descriptors, etc.), then destructors are (POSIXProcessState -> POSIXProcessState) functions. > You can't create, destroy, or manipulate a doubly linked list or a tree with backpointers in safe Rust. ...
Maybe forward pointer/backpointer pairs need to be a language level concept. You can define abstractions like this using unsafe code just fine. It doesn't need to be part of the language. (Think about how C++ "smart pointers" work: it's just a library.) |
|