Re:A Dangerous Obsession with Primitives
by skybrian on Thursday May 31, 2012 @04:36PM
(#4050211)
That's language-specific advice. Go handles this much more elegantly. You can create a Celsius type very simply:
type Celsius float64 // Temperature in degrees Celsius
It's no harder to use than 'typedef' in C and similarly it doesn't get in your way, but you get a real type and nice errors when you screw up. There's no reason not to do it right away.
type Celsius float64 // Temperature in degrees Celsius
It's no harder to use than 'typedef' in C and similarly it doesn't get in your way, but you get a real type and nice errors when you screw up. There's no reason not to do it right away.