Hacker News new | ask | show | jobs
by kiitos 995 days ago
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.
1 comments

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.
> alias and type redefinitions are conceptually the same.

In Go, they are not. Aliases establish precise equivalence between types, type redefinitions establish new types altogether.