There are a few Any. I don’t know if this means the compiler cannot determine the return type of the function f in compile time. I added Float64 as the return type, but it seems only to do a type conversion at the end, and does not tell the compiler the information of the function.
I’m curious if this would affect the performance. Thanks.
Function is an abstract type. Each function has its own type. If you want your struct to contain a function, for performance reasons use a type parameter:
I think I would like to go with the 2nd approach, but the issue is that the type valT should be inferred from the type of t, which is myT{valT, ...}. If I parametrize the whole field, that information seems hidden. Of course I can provide it explicitly, but I’m curious if I can make the compiler infer this information.