2 ms·
> Whole-program analysis is not tractable (i.e., not scalable) ... in the general case. There are many function (sub-)graphs where this is not only tractable b
by account42 2y ago
> Whole-program analysis is not tractable (i.e., not scalable)
... in the general case. There are many function (sub-)graphs where this is not only tractable but actually trivial. Leave annotations for the tricky cases where the compiler needs help.
> fn f4<'a>(map: &'a Map<i32, i32>, key: &i32) -> &'a i32 { ... }
The problem is not that you can't understand what this means but that it adds too much noise which is both needless busywork when writing the function and distracting when reading the code. There is a reason why many recent C++ additions have been reducing the amount of boilerplate you need to write.
There have been plenty attempts at safty annotations. There is a reason why they have not been adopted by most projects.
- simonask 2y agoI think you might be surprised how rare explicit lifetime annotations actually are in Rust code. But, to the point: It precisely isn’t “noise”. It’s important information that any competent C++ developer will immediately look for in documentation, or worse, by analyzing the code. It’s not distracting - it’s essential. Aside: I’m very confused by your assertion that C++ has been reducing boilerplate. It feels like every couple of years there’s another decoration that you need to care about. The only reduction I can think of is defaulted/deleted constructors and assignment ops? But that feels self-inflicted, from a language design perspective.