4 ms·
I think the "unknowable" lifetimes are C++'s own making. It's like types in statically vs dynamically typed languages. Types are unknowable at compile time wh
by pornel 2y ago
I think the "unknowable" lifetimes are C++'s own making.
It's like types in statically vs dynamically typed languages. Types are unknowable at compile time when the compiler doesn't force them to be static.
And similarly ownership and lifetimes are "dynamically typed" in C++, because the compiler doesn't force them to be rigidly declared like in Rust.
- kccqzy 2y agoUnknowable lifetimes are a necessary evil. Rust has them too. It's called RefCell. Without RefCell there are very useful things that are impossible to write in safe Rust.
- pornel 2y agoBut this needs to be explicit, and doesn't undermine other statically-known lifetimes (pointers to the inner cell can't escape it). Just like statically typed languages have some dynamic dispatch features, but despite that still most of their types can be known with certainty.