Skip to content

Implement Overload decorator in pure python #166

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

Merged
merged 3 commits into from
Feb 24, 2022

Conversation

Smit-create
Copy link
Collaborator

# This might fail for the cases when arguments don't match
ann_dict = getcallargs(func, *args, **kwargs)
except TypeError:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the arguments don't match, shouldn't we rather raise an exception that the arguments don't match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose, the list contains two functions foo(a) and foo(a, b), then, foo(1, 2) will raise an error if we use getcallargs on the first function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. We should determine which of the overloads contains two integer arguments in this case. And just call that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right!

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this looks good and we can merge it. I left a comment above about what happens if the arguments don't match, but I think it can be fixed later.

@certik certik merged commit bfb1bfd into lcompilers:main Feb 24, 2022
@Smit-create Smit-create deleted the overload1 branch February 24, 2022 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants