3 ms·
>Why do you make me lose the ability to use Elixir's admittedly powerful Pattern matching on arity feature? If every first class fuction had to check for arity
by lvass 3y ago
>Why do you make me lose the ability to use Elixir's admittedly powerful Pattern matching on arity feature?
If every first class fuction had to check for arity at runtime, wouldn't there be a performance cost? Also would reduce drastically the amount of errors caught at compile time. Maybe a different mechanism for dispatching like that (a macro?) could be done, how useful would that be?
- jakear 3y agoThere already must be a arity check at some point, no? If the type contained the set of airties the lambda accepts rather than just the singe one, all the same type checking could be done when it's already done.
- lvass 3y agoThere's no type checking on function dispatch unless guards are explicitly added. The arity dispatch for functions captured into first class is done at compile time and require explicitness. That said, I think you can create your own dispatch macro that's probably as efficient as possible for doing what you proposed.