4 ms·
The difference is that a compiler knows all about the memory model of the language it's compiling. So it can enforce rules that guarantee you handle memory safe
by wavemode 2y ago
The difference is that a compiler knows all about the memory model of the language it's compiling. So it can enforce rules that guarantee you handle memory safely.
But it knows nothing about your other effects. The most it can do is force you to annotate that an effect is happening. It can't help you verify correct behavior of that effect.
- jiggawatts 2y agoThe obvious next step is to give the compiler the information it needs. The effect types could contain constraints similar to how Rust traits work.
- swiftcoder 2y agoThe compiler knew next to nothing about the memory model before we started annotating lifetimes. Annotating effects is a potentially reasonable next step. (I say "potentially", because even just annotating lifetimes is already considered a DX nightmare by a lot of people)
- gergo_barany 2y ago> The compiler knew next to nothing about the memory model before we started annotating lifetimes. Compilers for garbage compiled languages have always had to reason about the memory model. Compilers for languages with obligatory bounds checks have always had to reason about the memory model. Compilers for multi-threaded languages have always had to reason about the memory model. Even "good old C" compilers had to reason about the memory model when it came to volatile variables. Rust didn't invent the concept of a memory model, and Rust's lifetimes are only a small part of its memory model.