When defining a functor should the struct be subtyped from Function
?
For instance
struct foo <: Function
a
b
end
function (functor::foo)(x, y)
return functor.a*x + functor.b*y
end
or just is fine?
struct foo
a
b
end
When defining a functor should the struct be subtyped from Function
?
For instance
struct foo <: Function
a
b
end
function (functor::foo)(x, y)
return functor.a*x + functor.b*y
end
or just is fine?
struct foo
a
b
end
No, the functor is like a closure, it is a function and the struct is a parameter, which can be of any type.