Re:Why you should, actually, rewrite some of it in Rust
by danenania on Wednesday July 12, 2017 @03:47PM
(#14755954)
Is there anything that prevents this conversion of raw pointers to references from being automatable as well?
[ Parent
| on HN ]
Re:Why you should, actually, rewrite some of it in Rust
by ameliaquining on Wednesday July 12, 2017 @04:00PM
(#14756094)
Rice's theorem.
That's an overly glib answer. The fully general form of this problem is undecidable, but it would be theoretically possible to build a "reverse borrow checker" that analyzes a Rust program, detects raw pointers that are provably used exclusively in ways compatible with Rust's lifetime semantics, and converts them to references. But it would probably be a fairly major project requiring lots of specialized knowledge, because lifetime semantics are complicated. Nobody has attempted it yet as far as I know, although the author of Corrode has expressed interest.
Re:Why you should, actually, rewrite some of it in Rust
by steveklabnik on Wednesday July 12, 2017 @03:56PM
(#14756048)
If C was able to encode Rust's semantics around references, you wouldn't need Rust in the first place.
You might be able to get it to work sometimes for a very simple subset. I'd be extremely skeptical that it'd be very useful, though.
Re:Why you should, actually, rewrite some of it in Rust
by dllthomas on Thursday July 13, 2017 @01:52AM
(#14759014)
I agree with "sometimes, for a very simple subset" but I think there's a good chance that can still be very useful. A lot of uses just are super simple, and that may be obvious to the computer in cases that aren't obvious to the human. If we can remove the need for the human to reason about those, that can be a big help.