3 ms·
Rust's borrow checker isn't a type system. It's a static analyzer that tries to determine if it can figure out when to free your allocation.
by halpert 5y ago
Rust's borrow checker isn't a type system. It's a static analyzer that tries to determine if it can figure out when to free your allocation.
- andrewjl 5y agoI'm not deeply familiar with Rust borrow checker, but my understanding is that Swift will in the near-future support move only types. Are those not somewhat similar to what Rust has? See here for more re Swift: https://github.com/apple/swift/blob/main/docs/OwnershipManifesto.md#non-copyable-types https://github.com/apple/swift/blob/main/docs/OwnershipManif...
- dragonwriter 5y ago> Rust's borrow checker isn't a type system No, it's the thing that enforces a type system. The borrow/move semantics it enforces are a (part of a) type system.
- teakettle42 5y agoWhy do you think that’s not a type system? Literally all type systems could be described as “a static analyzer” that tries to assign and validate properties over the code it’s analyzing. All compilers also rely on the results of that static analysis to direct codegen. Rust’s type system implements substructural typing, and the borrow checker is an integral element of that type system.
- halpert 5y agoBased on your definition, then any static analyzer is a type system, because type information and the usage of those types is basically all that’s available for static analysis. Types define what operations can be performed. The borrow checker looks at allocations and determines when they can be freed. It really has nothing to do with types. An ideal implementation of the borrow checker could be totally type unaware and work with dynamically typed languages.
- dllthomas 5y ago> It really has nothing to do with types. I was under the impression that it's substantially an implementation of an affine type system (https://en.m.wikipedia.org/wiki/Substructural_type_system https://en.m.wikipedia.org/wiki/Substructural_type_system). Probably you could build such a thing without thinking about types per-se, but I don't think the designers of Rust did that, and I am not sure that makes it "not a type system" anyway. > any static analyzer is a type system "Any static analysis checking correctness is either a linter or a type checker" isn't a claim I would make, but I am not sure offhand how I would argue against it.