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

Add support for checking arguments that can be implicitly cast during overload resolution #4

Merged
merged 3 commits into from
Jul 24, 2023

Conversation

sudo-panda
Copy link
Contributor

No description provided.

Copy link
Owner

@wlav wlav left a comment

Choose a reason for hiding this comment

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

Why is #include "CPPMethod.h" needed in CPPOverload.cxx? It should be independent and only use the PyCallable base class. (I also don't see a reason in the code changes to add that include.)

For clarity: 1) use return nullptr on error return. That way there is no mistake in error returns in case newmeth happens to be set, as can be done now. 2) if newmeth declaration is put at initializatioon, then that reduces the chance for bugs later. 3) Don't use magic 10 * n to drive logic. From reading, that magic is simply saying "no matching score found, as all were INT_MAX." Simply use an additional boolean variable for that.

@sudo-panda
Copy link
Contributor Author

Why is #include "CPPMethod.h" needed in CPPOverload.cxx? It should be independent and only use the PyCallable base class. (I also don't see a reason in the code changes to add that include.)

For clarity: 1) use return nullptr on error return. That way there is no mistake in error returns in case newmeth happens to be set, as can be done now. 2) if newmeth declaration is put at initializatioon, then that reduces the chance for bugs later. 3) Don't use magic 10 * n to drive logic. From reading, that magic is simply saying "no matching score found, as all were INT_MAX." Simply use an additional boolean variable for that.

Fixed!

@sudo-panda
Copy link
Contributor Author

Added some more changes to reduce coupling.

This function rates the compatibility of the supplied arguments with
the parameters of the function.
The lower the score the better the match, zero being the best match.
This overload allows the supplied arguments to be implicitly casted
to match the parameters of the function.
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