3 ms·
It means I cannot fully specify the type of function my interface expects as an argument. A function is of type ‘Function’. There is no way to define it with t
by zeec123 5y ago
It means I cannot fully specify the type of function my interface expects as an argument.
A function is of type ‘Function’. There is no way to define it with the type of its argument or the type of what it returns.
- eigenspace 5y agoActually, Julia functions are all subtypes of Function. Every julia function has a unique type. We don't parameterize a function by it's input and return types because functions are extremely polymorphic in julia. However, there's lots of tricks one can do to dispatch on whether or not a given function have methods that satisfy some sort of interface, see here: https://github.com/oxinabox/Tricks.jl#we-can-use-static_hasmethod-to-declare-traits https://github.com/oxinabox/Tricks.jl#we-can-use-static_hasm... Using this technique, you can do compile time dispatch on things like input and return types.
- saiojd 5y agoFunctions are polymorphic in many languages that let you annotate the their types. The concern is not really for dispatch here, it's for readability/correctness.
- eigenspace 5y ago> The concern is not really for dispatch here, it's for readability/correctness. Then dispatch to an error.