by cjslep · 7y ago · 0 comments
func myBlah(thing interface{}){
switch thing.(type) {
case int:
// handle my int
case string:
// handle my string
default:
// default handling
}
}[0] https://github.com/go-fed/activity/blob/master/streams/gen_t...
// proposed
func Print2(type T1, T2)(s1 []T1, s2 []T2) { ... }
vs // less noise
func Print2(s1 []'T1, s2 []'T2) { ... }
This proposal does -not- seem to be informed by the same 'outer space' mindset that gave us the Go language. A reminder that mere capitalization in Go language informs visibility and access.Beyond mere syntax issues, the semantics of generics itself is adding huge complexity to what is a very capable and accessible 80% language.
> func Print2(s1 []'T1, s2 []'T2) { ... }
where would you add the claim that T1 and T2 must obey some named "contract"?
He asked where you'd denote the contracts each type much obey (e.g. the focus being: in which place, assuming, I guess, that you intent to stray from the current proposal of defining that).
I did miss generics when I first started writing Go, but after doing so for about a year at work and 2 years before that, I don't find me missing them at all.