by randomdata · 2y ago · 0 comments
(* Pascal in 1970 *)
Planet = (Unknown, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune);
// C in 1989
enum Planet {Unknown, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune};
Plus type system guarantees, and in Pascal's case, run time capabilities to query enum values and ranges.Go's hack has barely anything to do with that.
Funnily enough, Algol 68 had sum types, although controversially so due to overhead concerns. If only Go had copied the state of programming before 1970, then we wouldn't have to listen to all the nonsense about enums sucking. Of course they suck – they are, and always will be, a hack to work around a limited type system.