[C++-sig] Re: Boost.Python not resolving overloads
dave at boost-consulting.com
Tue Sep 23 01:11:48 CEST 2003
"Niall Douglas" <s_sourceforge at nedprod.com> writes:
> On 20 Sep 2003 at 23:42, David Abrahams wrote:
>> > Might it be an idea in the name of flexibility that boost.python
>> > marks mixed static and non-static functions and tries matching the
>> > static one first. If that fails, then it makes the first parameter
>> > "self" and tries again.
>> It *might* be an idea. If you can figure out how to make it work,
>> I'll be glad to review your patch. From what I know about descriptors
>> and how method binding works, though, I bet it's nontrivial.
> <groan> I had an awful feeling you might say that.
> Ok, tell me this: is function::call() the right place to alter?
If I knew what the right place to alter was, I would probably think
it's easy. I don't. I don't think you could do it correctly just by
making changes in function::call.
> If so, it would appear to me to be trivial - just insert the object
> instance as the first parameter if all else fails.
That is *not* the right fix. A regular member function with signature
void (A::*)(A&, int);
might inadvertently be called via
without issuing an error. Errors are good. If you want the
library/language to guess at what you meant when you screw up instead
of telling you what went wrong, you should be using Perl, not Python.
> As for adding knowledge if there are mixed static and non-static
> methods, well, as I've said before in here I really don't understand
> most of Boost.Python. I would imagine though that just altering the
> parameter matching loop wouldn't cause any existing code to break -
> so it should be okay?
Not a chance, sorry.
I'll tell you what. Why don't you start by writing a doctest case
which would succeed only with your proposed feature, and also includes
calls like my example above that should fail overload resolution. We
can look that over, and if it's acceptable to me, you can try to
write a patch which makes the tests pass.
> Would I post a patch here, or to you directly? And is GNU diff format
Here and yes.
More information about the Cplusplus-sig