4 ms·
The lack of ADTs in mainstream languages is really quite baffling, given their obvious utility. Thankfully it looks like they’re trickling in via Typescript/Sw
by akavi 7y ago
The lack of ADTs in mainstream languages is really quite baffling, given their obvious utility.
Thankfully it looks like they’re trickling in via Typescript/Swift/Kotlin.
- sambal 7y agoDo TS and Kotlin support them now? Last I checked TS was relying on string comparisons and Kotlin wasn’t even bothering outside sealed classes
- sixbrx 7y agoTS is a bit more powerful than it appears here, because string literal values are recognized at the type level, so can be checked by the compiler when distinguishing cases. See for example: "Discriminated Unions" at https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions https://www.typescriptlang.org/docs/handbook/advanced-types.....