[C++-sig] strange behavior with respect to numeric and Booleanoverloads

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Mar 19 17:10:39 CET 2009


The comprehensive solution sounds like a project. Do we have someone to work on this?

I'm asking because I think Troy's proposed simple solution is better than the status quo.



----- Original Message ----
From: David Abrahams <dave at boostpro.com>
To: Development of Python/C++ integration <cplusplus-sig at python.org>
Sent: Wednesday, March 18, 2009 12:15:15 PM
Subject: Re: [C++-sig] strange behavior with respect to numeric and Booleanoverloads


on Wed Mar 18 2009, "troy d. straszheim" <troy-AT-resophonic.com> wrote:

> The current rule for overload resolution are simply 'first match in reverse order of
> registration'.  You could relatively easily make this 'first match in forward order of
> registration'.   The library currently has no notion of one function being a better
> match than another, for a given set of arguments.  It looks like it would be
> interesting enough to implement, but it isn't clear what those rules would be or if
> the runtime cost would be worth it.  

I think we know what the rules should be; Daniel W. implmented something
like that for Luabind.

> For instance, this situation:
>
>   void fn_di(double, int);
>   void fn_id(int, double);
>
>   def("f", fn_di);
>   def("f", fn_id);
>
>   >>> f(3,3)
>
> In C++, of course, that's a compile-time error.  In python, would you check all
> overloads for equally-good matches, and if so, throw some kind of
> ambiguous_function_call exception?

Probably.


More information about the Cplusplus-sig mailing list