4 ms·
I remember a couple of years ago a root exploit in Sudo that was the result of failing to check for a sentinel value, thinking “that is a bug that wouldn’t happ
by jackmott 3y ago
I remember a couple of years ago a root exploit in Sudo that was the result of failing to check for a sentinel value, thinking “that is a bug that wouldn’t happen in Rust, even though it isn’t related to memory safety!”
Rust enums are sum types, and imho are one of the few unambiguously good language feature ideas. I miss them any time I use a language where they are not built in. F# is another nice language where they are first class and where I first got familiar with them
- Karellen 3y ago> Rust enums are sum types, I wouldn't mind so much if they just called them "sum types" or "tagged unions", or even some other new name. Reusing the existing name "enum" from other languages, but differently from the way all those other languages have used it for 45 gorram years, is freaking maddening.
- n_plus_1_acc 3y agoThat's inherited from OCaml I think. https://www.ocamlwiki.com/wiki/Enum https://www.ocamlwiki.com/wiki/Enum
- ode 3y agoNobody in the OCaml community commonly refers to them as Enum's today or any time recently (maybe they were at the time Rust was created though? IDK). They're usually called 'variants'.
- debugnik 3y agoI don't think so, OCaml consistently calls them "variant types". I don't know who wrote that page, but that wiki didn't even exist before September and it isn't endorsed by ocaml.org, so I suggest you don't consider it authoritative.
- cyber_kinetist 3y agoSwift and Scala also uses the enum keyword to define sum types, and their history goes earlier than Rust, so now you have multiple languages to yell at!
- Karellen 3y agoAre you sure about Scala? I'm not familiar with it, but looking at the documentation it seems that an enum is a set of values, not a set of types? https://docs.scala-lang.org/scala3/reference/enums/enums.html https://docs.scala-lang.org/scala3/reference/enums/enums.htm...