I would like to have the following:
import _Differentiation
struct S {
var f: @differentiable(reverse) (Double, Double) -> Double
}
but the compiler complains Error: Abort trap: 6
and the start of the stack trace is
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 269.
If the member variable is a function of one parameter, the program builds:
import _Differentiation
struct S {
var f: @differentiable(reverse) (Double) -> Double
}
but two or more parameters is not allowed.
We can write a function that has a differentiable function of two parameters as a parameter:
import _Differentiation
func g(f: @differentiable(reverse) (Double, Double) -> Double) {
// function body
}
If a function can have this type of parameter, why can a struct not have a member variable of this type?