News for hackers. Stuff that matters.
Re:Let the Type System do the Work by Jtsummers on Monday April 21, 2014 @01:31PM (#7622340)
That seems useful, but dangerous. If you specify (for some reason) both a centimeter and inches type, would you be able to mix them in expressions without warnings?

--------

Per [1] it seems that since both would be named types you wouldn't be able to assign one to the other without explicit conversions. If my reading is correct, then that addresses my concern. It's things like storing a `float` to a `inch` type that can happen without explicit conversion as long as `inch` has float as its base type.

[1] http://golang.org/ref/spec#Properties_of_types_and_values

Re:Let the Type System do the Work by skybrian on Monday April 21, 2014 @07:03PM (#7624566)
They are separate types, not a type alias, but some conversions are automatic. The rule for assignability also affects comparisons and function calls (including expressions containing them), but apparently not all expressions like I thought?