2 ms·
D's borrow checker simply keys off of the existing syntax: const a = 1; // a is immutable auto b = 1; // b is mutable const(int)* p; // pointer t
by WalterBright 4y ago
D's borrow checker simply keys off of the existing syntax:
const a = 1; // a is immutable
auto b = 1; // b is mutable
const(int)* p; // pointer to const
int* q; // pointer to mutable
There's no new syntax, the borrow checker just adds a layer of checks.
- maccam94 4y agoRust references are basically pointers with extra rules, so using a different symbol is reasonable, and rust is immutable by default rather than opt-in (which is an important design decision) so you have to have syntax to mark things as mutable. auto is horribly uninformative for new coders, and var is too overloaded to expect newbies to only use it for mutable variables.
- WalterBright 4y agoD doesn't use `var`.