I am curious about the utility of creating abstract or concrete subtypes of Function
.
Aside from syntactic convenience, I am not sure of the distinction between a singleton type that is given several methods and a function definition.
struct MulPlus1T end
mulplus1 = MulPlus1T()
(::MulPlus1T)(x) = x+1
(::MulPlus1T)(x,y) = x*y+1
I can add as many methods as I want to mulplus1
, so it seems to do everything a Function
can.
Then, what utility is there to making MyFuncType
a subtype of <:Function
? As far as I know, it would allow myfunc
to be used in methods of higher order functions that specifically demand that the argument isa Function
, but I usually do not see this in practice because it would exclude user defined callable objects (which perhaps might be a subtype of some other abstract type and thus cannot be a Function
).