Highly generic code has its own issues that I don’t think can be captured in the code. The way people try to capture it in the code would be like Haskell’s type system, but there are plenty of examples which would immediately fail if trying to use derived types (units is always one tricky example which breaks simple things like f(u::T,p,t)::T
). So anything in the code would only break examples, other than the code itself (i.e. looking at it and saying “the scalars should support sqrt
, …”). I’m not sure there’s a better solution than mass combinatoric testing, other than imposing an interface that locks out otherwise compatible types.
3 Likes