3 ms·
If I understand the article correctly (and I'm not a Rust programmer), the above is an optimization that permits the programmer to write code that is correct wi
by phoe-krk 3y ago
If I understand the article correctly (and I'm not a Rust programmer), the above is an optimization that permits the programmer to write code that is correct with regard to object lifetimes, but currently rejected by the compiler. This is because the current borrowing model is too simple to account for that particular case, and hence, a new model is being developed that makes compiling this code possible without sacrificing correctness.
But, still, the whole selling point of Rust is "flow-sensitive analysis (...) for a language feature that affects whether code is accepted or rejected". Accepting or rejecting some code based on whether it fits the memory model of that language is the main advantage that Rust has over other strongly typed statically compiled languages.
- rayiner 3y agoI wouldn’t say that’s the “whole selling point of Rust.” The borrow checker was based on lexical scopes, rather than the CFG, until last year.
- phoe-krk 3y agoThanks - I quoted too much of the parent, I've amended my comment.
- steveklabnik 3y ago“Until last year” is technically correct but not really accurate. Lifetimes were made non-lexical in 2018, but only for Rust 2018 code and newer. Last year is when they were made non-lexical for 2015 code as well. For the vast majority of Rust developers, lifetimes have been non-lexical for five years now.