If I have a function inside a struct and run that function inside another function, the output will be type-unstable.
Example:
struct StructWithFunction
func::Function
end
struct_with_function = StructWithFunction(+)
@inferred struct_with_function.func(2,3)
function test(struct_with_function)
struct_with_function.func(2,3)
end
@code_warntype test(struct_with_function)
As an interesting side note we’ve recently lost the ability to efficiently unbox functions from containers as currently FunctionWrappers.jl is required for that and it only works on 0.6. I’d be interested to know if functors of some kind would be efficient as a temporary work around.
Yay! At this point I’m just glad it’s there because honestly I had absolutely no clue how to do it myself. I checked to see if there were any in the past but I guess not recently. It’s scary not to at least have that functionality in a functional language like Julia. I don’t use it that often but when I do it doesn’t seem like there are many alternatives.
It works on the linux nightlies, that’s all I need
(As a fun example of where there seemed to be no good alternatives see my MOS 6502 simulator.)