5 ms·
It's nice how in Go you can alias a type to int, yet it is its own distinct type with compile time checks and explicit conversions. Definitely takes away all th
by tomlu 13y ago
It's nice how in Go you can alias a type to int, yet it is its own distinct type with compile time checks and explicit conversions. Definitely takes away all the boilerplate.
- pjmlp 13y ago> Definitely takes away all the boilerplate. Until you need to write generic code. Then it is casts everywhere and boilerplate to satisfy interfaces.
- dkuntz2 13y agoIf you need generics why are you writing in Go?
- pjmlp 13y agoI am not, left the language ecosystem before the 1.0 release. Might consider it again if a customer requires me to use it, otherwise I am happier with other more modern languages.
- drbawb 13y ago>... and boilerplate to satisfy the interfaces. Go actually provides facilities for embedding types which helps remove some of the unnecessary boilerplate from satisfying an interface.[1] Through embedding you can leverage the implementation of an existing type to satisfy an interface w/o writing methods to dispatch to that underlying type. [1]: http://golang.org/doc/effective_go.html#embedding http://golang.org/doc/effective_go.html#embedding
- pjmlp 13y agoI used Go quite a lot until version 1.0 got released. You are not explaining nothing new to me.
- pycassa 13y agoHaskell has both. You can have type synonyms that are not distinct to the original type according to the compiler and new types that are distinct to the original that doesn't even 'inherit' all the type classes of the original type. You have to specifically instantiate all the type classes you need.