Re:Compile-time safety for enumerations in Go
by kiitos on Sunday October 01, 2023 @10:56PM
(#37733436)
Technically not a type alias, just a normal type declaration. But yes, this is my point: you can't assume that an enum type will always be one of a fixed set of values that you've defined. You always have to do at least a little bit of runtime validation of the parameter. It's unavoidable.
[ Parent
| on HN ]
Re:Compile-time safety for enumerations in Go
by gabereiser on Monday October 02, 2023 @08:40AM
(#37737325)
alias and type redefinitions are conceptually the same. int and int_t are conceptually the same. I’m going to assume it’s my type, as defined in the signature of my method you’re calling. If you don’t adhere to the contract then the onus is on you. I’ll check existence, I’ll check conformity, but I won’t check that your string = my string.