Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not reference a function with a specific arity #1435

Open
jurgenvinju opened this issue Aug 5, 2020 · 1 comment
Open

Can not reference a function with a specific arity #1435

jurgenvinju opened this issue Aug 5, 2020 · 1 comment

Comments

@jurgenvinju
Copy link
Member

Is your feature request related to a problem? Please describe.

When passing a function as a higher-order parameter I can only reference it by name, e.g:

higherOrderFunction(parameterFunction);

The problem is when parameterFunction is overloaded with multiple different argument arities. In this case the
type of parameterFunction is not a function anymore (the least upperbound of functions with different arities is value), so the code does not type-check.

Describe the solution you'd like

We could add a syntax and semantics for referencing functions by name + arity. Examples:

higherOrderFunction(parameterFunction:2);`
higherOrderFunction(parameterFunction.2);`
higherOrderFunction(parameterFunction(_, _);`
higherOrderFunction(parameterFunction(int, int);)`

The last example would also filter out overloaded alternatives with parametertypes which are not intersecting with int and int, respectively, but that is more than I'm asking for here. Although it would be the most general thing we can think of to reference specific function alternatives from a set... so there's that.

Describe alternatives you've considered

Leaving it as is. The problem with that is that you'd have to take care not to overload with different arities if you want your functions to be reused in higher-order settings. That's not ok. Overloading is particularly useful when arities are different. You don't have to come up with new names.

@jurgenvinju
Copy link
Member Author

@PaulKlint @tvdstorm this is a small future enhancement; I think it would close the circle regarding the simplification process of the type-system regarding (higher-order) function types. There exists no more (complex) union type for functions (overloadedfunctiontype), and this is one of the final issues that remains in order to clean up after it.

Current workaround is to rename functions with different arities :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant