Package level generics may look less confusing.
package abc(Key,Value)
contract CompileCheck(a1 Key, a2 Value) {
//...
}
type Pair struct {
K Key
V Value
}
func NewPair(k Key, v Value) Pair {
return Pair{K: k, V: v}
}
package xyz
import "abc(int32,float32)" myabc
func newPair() myabc.Pair {
return myabc.NewPair(1, 1.0)
}
Introduce two step compilation. Firstly create abc[Key,Value].lib from source. Then create abc(int32,float32).a from abc[Key,Value].lib . Both abc[Key,Value].lib and abc(int32,float32).a can be saved to reduce next compilation time.
I tried to make it impossible that define both
abc(K,V)
andabc(X,Y)
.You are right. It's a better to let the compiler show an error in such cases.