Hacker News new | past | comments | ask | show | jobs | submit login

Immutable back references seem limiting... because how are you inserting things if you have a reference saying the thing you are inserting it into can't mutate.

If you're willing to use locks or something for interior immutability though... I think it should already be possible. It works in a toy example: https://play.rust-lang.org/?version=stable&mode=debug&editio...




Right. You can also do that with Rc and borrow.

When nothing in the call tree is using the parent link, it should be OK to add children. That's potentially checkable at compile time.


Thinking about this some more, that example has a mutex in a single thread program. If it's ever reached while locked, the program is stuck. This is a demonstration that the backlink problem and single-thread deadlock detection are equivalent.

Work on compile time deadlock detection for Rust is underway.[1] It's complicated, but do-able.

[1] https://github.com/hlisdero/cargo-check-deadlock




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: