News for hackers. Stuff that matters.
Re:Compile-time safety for enumerations in Go by throwaway894345 on Friday September 29, 2023 @11:20AM (#37705554)
You're not changing the underlying value of `color.Red`, you're changing the variable (in other words, `PrintColor(color.Red)` will still print `red`). If that's the point you're intending to make, then couldn't you make it more easily with this?:

    c := color.Red
    c = Color("orange")
    PrintColor(c)
Re:Compile-time safety for enumerations in Go by masklinn on Friday September 29, 2023 @11:36AM (#37705800)
> You're not changing the underlying value of `color.Red`

Doesn't matter, the point is they're getting in a value which is not part of the defined set, demonstrating that this emulation is not actually typed-safe.

> If that's the point you're intending to make, then couldn't you make it more easily with this?:

    cannot convert "orange" (untyped string constant) to type Color
Re:Compile-time safety for enumerations in Go by throwaway894345 on Saturday September 30, 2023 @03:13AM (#37713360)
Yeah, I thought Color was `type Color string`. I misunderstood what he was doing.