Worst ideas/features in programming languages?
newshound2 at digitalmars.com
Sat Jan 8 00:21:20 UTC 2022
On 12/29/2021 12:10 AM, Petar Kirov [ZombineDev] wrote:
> The typestate  design pattern. In languages that support some form of affine
> types  like Rust (*), this design pattern can be used to prevent classes of
> programmer errors at compile-time, while the best C++ and D can do is use
> `assert` at run-time to facilitate detecting them. Here's a few articles that
> showcase this in Rust:
> * https://cliffle.com/blog/rust-typestate/
> * https://rustype.github.io/notes/notes/rust-typestate-series/rust-typestate-part-1
> * https://docs.rs/typestate/latest/typestate/
> (*) Technically, affine types are about using a variable at most once. In Rust,
> if a type doesn't implement the Copy / Clone traits , variables of that type
> have move semantics - that is, they can't be used after they have been passed to
> a function that takes them by value (passing ownership). But they can be still
> passed multiple times to functions take them by reference (borrowing).
> : https://en.wikipedia.org/wiki/Typestate_analysis
> : https://en.wikipedia.org/wiki/Substructural_type_system
> : https://doc.rust-lang.org/std/marker/trait.Copy.html
Thanks, I did not know that.
More information about the Digitalmars-d