-
Notifications
You must be signed in to change notification settings - Fork 77
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
Should the type checker forbid function overloading across different scopes? #767
Comments
Probably very little would happen -- this happens right now in the checker more by accident (I wasn't very creative in coming up with new names), and would be easy to detect and flag. The other alternative would be to say that it creates a new function, not an overload, which is probably the intended behavior in most of the cases where this would arise, but that has the problem of being potentially confusing. |
Just a note, the example:
is type incorrect if we talk about the overloading variant, since both alternatives are for the same pattern. |
I think the function scope is a real scope with shadowing, so function names should be shadowed as well. One nice point of a local function is that you can pick a nice short name and you don't have to think hard about that, with the current semantics the programmer actually may accidentally overload another function without realizing. |
Note: the actual case in the checker has been removed, but we still need to handle the situation, one way or another, more generally. |
Yes I have noticed. I can now compile |
Hi @PaulKlint I knew that you knew, it's just ridiculously early at the airport so I'm updating status messages on GitHub :) |
Take care! Maybe a brief summary how your talks went via a more private channel? |
On 7 March 2015 14:31:12 CET, Paul Klint notifications@github.com wrote:
We're certainly very happy with his OOPSLE talk. I think he may even have mentioned Rascal once or twice... |
@anyahelene sounds good, thanks! |
At the moment the compiler assumes that all overloaded functions are declared in the same scope, be it the module scope or a nested function scope. For instance, the following two examples are fine:
and
However, triggered by code examples in
CheckTypes.rsc
(one of several exhibits:addAlias
) the following structure is also used whereh
is overloaded but the versions are defined in different scopes:I can probably modify the compiler to support this but this may have extra costs in compiler complexity and execution overhead.
_Question_: what happens if we forbid this kind of overloading across different scopes?
The text was updated successfully, but these errors were encountered: