Roger Peppe
Sep 4, 2018 · 1 min read

> “generic functions are just first-class functions that operate on types”

Nit pick, they’re not first-class functions, because they can’t be manipulated as first class objects. They can be called but they can’t be otherwise manipulated or used.

For example we can’t do:

func X(type T)() {}
var x = X

contract copyable(t T, u U) {
len(t)
len(u)
t[0] = u[0]
}

This kind of thing makes me deeply uneasy. I believe we should define contracts in such a way that it’s trivial to look at the contract and decide a) what kinds of types you can pass to it and b) what you can do with values of those types. I think that almost every operation should be explicitly enumerated rather than implied “because all types with this property also have this other property”. But you know that already as you read my post :)