Struct with a field of type `Function`

Please note that, as with any parametric data type, any function you create that take a MyType{F, A} will probably be recompiled and specialized for each call with MyType of a different F and A. You may want to check in your use case how the extra specializations triggered by MyType{F, A} compare to the lack of specializations of just MyType (i.e., if the overhead is worth it). Or go by a third path an keep using MyType{F, A} but annotate some method parameters with @nospecialize.

5 Likes