3 ms·
But on the other hand the motivating problems noted in C++ don't exist. It is 100% legal to completely rebind a variable in the same scope, it never warns that
by vlovich123 2y ago
But on the other hand the motivating problems noted in C++ don't exist. It is 100% legal to completely rebind a variable in the same scope, it never warns that `_` variables are unused nor about unused `_` prefixed variables. I think `_` being immediately dropped is maybe one of those unfortunate decisions we'll look back in 20 years and regret.
- tempodox 2y agoEver heard of `-Wunused-variable`? > rebind a variable in the same scope But only re-assigning values of the same type. Otherwise: int x = foo(); int x = bar(); error: redefinition of 'x' and, int x = foo(); long x = bar(); error: redefinition of 'x' What are you talking about?
- vlovich123 2y agoIn rust it’s perfectly legal to do let x = foo() let x = bar() Regardless of the return types. That obviates a lot of the motivating problem that the c++ paper is contorting itself to fix
- tempodox 2y agoYes, borrowing some stuff from functional languages (like the ability to shadow variables) gave Rust a good boost in ergonomics.