-
Notifications
You must be signed in to change notification settings - Fork 2
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
Function overloading #6
Comments
After an extended discussion with @laokaplow, the proposed syntax for this feature has changed. If we are given
allowing the second declaration to overload the first declaration implicitly changes the type of This implicit type re-interpretation can be avoided by requiring all function overloads to be specified as part of a single declaration statement, like so:
The ampersand indicates AND, shortened to the ampersand by common convention. This ampersand syntax is the new proposed syntax for function overloading. Sum types are a significant enough feature to warrant their own issue (#40). |
@laokaplow observes that there is no semantic reason to require the same return type for all function variants, since the parameter list uniquely identifies each function variant. |
There is some awkwardness in this implementation: both function and multi-variant function classes still exist. This is primarily because of the necessity to differentiate function specifiers and function declarations (the later has parameter names) for single-variant functions, which is not necessary or desired for multi-variant functions. |
Note: we must be sure the side-by-side declarations
f:= (a:int) -> int
andf:= (a:int=2) -> int
are handled correctly (they have the same signature, but one has a default value)The text was updated successfully, but these errors were encountered: