[C++-sig] Boost.Python Function overload resolution order

David Abrahams dave at boost-consulting.com
Wed Nov 27 03:41:16 CET 2002


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> --- David Abrahams <dave at boost-consulting.com> wrote:
>> I just discovered something surprising in Boost.Python's function
>> overload resolution: overloads are tried in the _reverse_ order in
>> which they are def'ed. I actually thought it worked the opposite way!
>
> Great, finally I know why I was confused by some of your earlier
> postings!

Are you sure that isn't just becausen I vocatulate too ferixtably?

>> If we change the rules so that the first def() is tried first, g
>> will neve be called. However, I consider the current rule to be
>> counter-intuitive and surprising. Quite a dilemma.
>> 
>> Opinions?
>
> I have a module A def'ing some overloads for foo(). Then I have
> another module B which implicitly imports A and def's some more
> overloads in the scope() of A.  In my particular case the overload
> resolution is unambiguous, so I don't really care. However, in
> general it could be advantageous if overloads def'ed by higher level
> modules get attention before any overloads def'ed by lower-level
> modules. For this scenario the current implementation seems ideal.

Why do you suppose that higher-level modules will be loaded second in
general?

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list