Worst ideas/features in programming languages?

Walter Bright 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 [1] design pattern. In languages that support some form of affine 
> types [2] 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 [3], 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).
> 
> [1]: https://en.wikipedia.org/wiki/Typestate_analysis
> [2]: https://en.wikipedia.org/wiki/Substructural_type_system
> [3]: https://doc.rust-lang.org/std/marker/trait.Copy.html
> 
> 

Thanks, I did not know that.


More information about the Digitalmars-d mailing list