Signature matching, manual intervention.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Signature matching, manual intervention.

Rene Rivera-2
So I was talking with JW (John W. since there are two Johns I keep
having to refer to)  and he asked a rather simple question when I was
mentioning the Luabind signature matching:

   How can you choose a particular overload to call, if you know which
one you want?

In particular the example he cited was of having two methods overloaded
on different subclasses of a common class. So my almost immediate answer
was:

   You can't, since you'll get an error in C++ anyway.

But then I realized that one can, with some clever casting, and function
pointer. So my question now is:

   Should forcing a call to a specific overload be supported?

And the obvious follow up: How?


--
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Reply | Threaded
Open this post in threaded view
|

Re: Signature matching, manual intervention.

Roman Yakovenko
On 8/7/07, Rene Rivera <[hidden email]> wrote:

> So I was talking with JW (John W. since there are two Johns I keep
> having to refer to)  and he asked a rather simple question when I was
> mentioning the Luabind signature matching:
>
>    How can you choose a particular overload to call, if you know which
> one you want?
>
> In particular the example he cited was of having two methods overloaded
> on different subclasses of a common class. So my almost immediate answer
> was:
>
>    You can't, since you'll get an error in C++ anyway.
>
> But then I realized that one can, with some clever casting, and function
> pointer. So my question now is:
>
>    Should forcing a call to a specific overload be supported?

I think I don't completely understand you. Do you mean from the
"target" language ( Python or Lua for example )?

If so, than in my opinion the answer is: yes.
Use case:

void do_smth( bool )
void do_smth( int )

Today Boost.Python selects what function to call based on registration
order. The final user has no way to select the right function.

Another very important use case is error reporting. There are too many
times I found myself and other users in situation where I try to
understand why Boost.Python rejects to call one of the exposed
overloaded functions. If you provide the way to specify what function
to call the error report could be very very concrete, instead of
"unable to find function, which takes the arguments you pass" or
something like this.

> And the obvious follow up: How?

May be by allowing lang-binding user  to define alternative name?

def( "do_smth"
       , "do_smth_that_takes_5_arguments"
       , .... );

Thus the extension user will be able to specify directly what function to call.

import my_extension

my_extension.do_smth_that_takes_5_arguments( .... )


--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Reply | Threaded
Open this post in threaded view
|

Re: Signature matching, manual intervention.

David Abrahams
In reply to this post by Rene Rivera-2

on Tue Aug 07 2007, Rene Rivera <grafikrobot-AT-gmail.com> wrote:

> So I was talking with JW (John W. since there are two Johns I keep
> having to refer to)  and he asked a rather simple question when I was
> mentioning the Luabind signature matching:
>
>    How can you choose a particular overload to call, if you know which
> one you want?
>
> In particular the example he cited was of having two methods overloaded
> on different subclasses of a common class. So my almost immediate answer
> was:
>
>    You can't, since you'll get an error in C++ anyway.
>
> But then I realized that one can, with some clever casting, and function
> pointer. So my question now is:
>
>    Should forcing a call to a specific overload be supported?

IMO there is no need to support that other than by choosing the
argument types carefully.

> And the obvious follow up: How?

By choosing the actual argument types carefully :-)

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

The Astoria Seminar ==> http://www.astoriaseminar.com


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Reply | Threaded
Open this post in threaded view
|

Re: Signature matching, manual intervention.

David Abrahams
In reply to this post by Roman Yakovenko

on Wed Aug 08 2007, "Roman Yakovenko" <roman.yakovenko-AT-gmail.com> wrote:

> I think I don't completely understand you. Do you mean from the
> "target" language ( Python or Lua for example )?
>
> If so, than in my opinion the answer is: yes.
> Use case:
>
> void do_smth( bool )
> void do_smth( int )
>
> Today Boost.Python selects what function to call based on registration
> order.

We plan to do something smarter for langbinding.

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

The Astoria Seminar ==> http://www.astoriaseminar.com


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Reply | Threaded
Open this post in threaded view
|

Re: Signature matching, manual intervention.

Roman Yakovenko
On 8/8/07, David Abrahams <[hidden email]> wrote:

>
> on Wed Aug 08 2007, "Roman Yakovenko" <roman.yakovenko-AT-gmail.com> wrote:
>
> > I think I don't completely understand you. Do you mean from the
> > "target" language ( Python or Lua for example )?
> >
> > If so, than in my opinion the answer is: yes.
> > Use case:
> >
> > void do_smth( bool )
> > void do_smth( int )
> >
> > Today Boost.Python selects what function to call based on registration
> > order.
>
> We plan to do something smarter for langbinding.

:-), what about second use-case? Will you provide in exception
information why the library "refuses" to call a function from a set of
overload ones?

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
Reply | Threaded
Open this post in threaded view
|

Re: Signature matching, manual intervention.

David Abrahams

on Wed Aug 08 2007, "Roman Yakovenko" <roman.yakovenko-AT-gmail.com> wrote:

> On 8/8/07, David Abrahams <[hidden email]> wrote:
>>
>> on Wed Aug 08 2007, "Roman Yakovenko" <roman.yakovenko-AT-gmail.com> wrote:
>>
>> > I think I don't completely understand you. Do you mean from the
>> > "target" language ( Python or Lua for example )?
>> >
>> > If so, than in my opinion the answer is: yes.
>> > Use case:
>> >
>> > void do_smth( bool )
>> > void do_smth( int )
>> >
>> > Today Boost.Python selects what function to call based on registration
>> > order.
>>
>> We plan to do something smarter for langbinding.
>
> :-), what about second use-case?

Which use case is that?

> Will you provide in exception information why the library "refuses"
> to call a function from a set of overload ones?

Doing any better than we're doing now would at best be really, really
hard.  No C++ compiler does better than, "actual arguments <argument
types> don't match any of <list of overloads>."  I think there's a
good reason for that.

If you can come up with an algorithm that gives better information
that doesn't mislead as often as it enlightens, I'd be interested.

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

The Astoria Seminar ==> http://www.astoriaseminar.com


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Boost-langbinding mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding