4 ms·
> If it can accept one ambiguous type throughout, there's no reason it could not accept multiple types throughout. I'm sure it could, but only at the expense o
by TheCoelacanth 12y ago
> If it can accept one ambiguous type throughout, there's no reason it could not accept multiple types throughout.
I'm sure it could, but only at the expense of ballooning to an even more disproportionate length.
- falcolas 12y ago> I'm sure it could, but only at the expense of ballooning to an even more disproportionate length. If you looked at the code, you would see that it could be done in zero additional lines of code if he wanted, or in one if he wanted to be explicit. if !goodFunc(fn, elemType, zero.Type().Elem(), elemType) { str := elemType.String() panic("apply: function must be of type func(" + str + ", " + zero.Type().Elem().String() + ") " + str) } There would be a few other inline changes to add `zero` to the function calls (and fix the 0/1 cases), but they are all pretty trivial. If we want to be pedantic about it, the goodFunc call is not even technically required, it just makes the error output a bit better.