Hacker News new | ask | show | jobs
by mibsl 957 days ago
This is done so that the programmer doesn't have to reason about it. Polonius makes the compiler accept code that's obviously valid, but the current borrow checker isn't sophisticated enough to declare it as safe.

I've bumped into this kind of problem when writing rust, at first it was hard to understand why the compiler doesn't accept my code.

1 comments

This kind of control would drive me up the wall. If I write code and my logic is wrong I appreciate compiler being able to tell me to sod off. Doing it when the logic is perfectly valid is a turn off.
That's the draw of having a borrow checker, which is arguably the contributor to the biggest pain points of Rust. Everything is a tradeoff. Rust's "unsafe" blocks are also a tradeoff. To my understanding, Rice's theorem ensures that, for checking borrows, either all invalid programs and some valid programs are rejected, or all valid programs and some invalid programs are accepted. Given Rust's goal of overall safety, the conservative route (which rejects some valid programs) is favored.
>" the conservative route (which rejects some valid programs) is favored."

I understand it and consider it very reasonable choice given the goals. Still no fun ;)

Some languages require you to declare your variables, and if you use an undeclared variable, the compiler complains and refuses to emit any code. Is that a turn off for you, too?
>"Is that a turn off for you, too?"

Quite the opposite