For a function-like object, aka callable/functor, is there any problem with making it a subtype of Function
?
As in,
struct Polynomial{R} <: Function # XXX
coeffs::Vector{R}
end
(p::Polynomial)(t) = evaluate_polynomial(p, t) # see code in Julia docs
The point of this would be to be able to pass a Polynomial
object as a Function
argument, for example as the argument control
in a function discretize
defined as (among other methods)
function discretize(control::Function, tlist)
return [control(t) for t in tlist]
end
Of course, I’m not saying that all callables must/should be subtypes of Function
, but if they’re not subtypes of some other abstract type, is there a reason not to make them subtypes of Function
?