[tutorial] Auto-Overloading example bug?
Hi. I could be wrong, but it seems to me that the Boost.Python tutorials contains bug. ( http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#pyt...) The compiler ( I use msvc 7.1 ) is not able to compile the code. The main reason is that it can not decide what "f" to select. I mean, it does not know what address it should pass to "def" function. The same thing occurs for BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS. It seems to me that it is right. Some thoughts. I think, that in this case( auto-overloading example ) function "def" should not take reference to function. It should be enough to pass an instance of the constructed class. Same logic could be applied on class_::def method too. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Roman Yakovenko wrote:
Hi. I could be wrong, but it seems to me that the Boost.Python tutorials contains bug. ( http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#pyt... <http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#pyt...> )
The compiler ( I use msvc 7.1 ) is not able to compile the code. The main reason is that it can not decide what "f" to select. I mean, it does not know what address it should pass to "def" function. The same thing occurs for BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS. It seems to me that it is right.
Some thoughts. I think, that in this case( auto-overloading example ) function "def" should not take reference to function. It should be enough to pass an instance of the constructed class. Same logic could be applied on class_::def method too.
I am not quite sure what you mean. Please see defaults.cpp in the libs/python/test directory. The example compiles just fine with VC7.1. If you are not convinced, you might want to provide a minimal sample code that we can try. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel de Guzman wrote:
Roman Yakovenko wrote:
Hi. I could be wrong, but it seems to me that the Boost.Python tutorials contains bug. ( http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#pyt... <http://boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#pyt...> )
The compiler ( I use msvc 7.1 ) is not able to compile the code. The main reason is that it can not decide what "f" to select. I mean, it does not know what address it should pass to "def" function. The same thing occurs for BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS. It seems to me that it is right.
Some thoughts. I think, that in this case( auto-overloading example ) function "def" should not take reference to function. It should be enough to pass an instance of the constructed class. Same logic could be applied on class_::def method too.
I am not quite sure what you mean. Please see defaults.cpp in the libs/python/test directory. The example compiles just fine with VC7.1. If you are not convinced, you might want to provide a minimal sample code that we can try.
Ok, disregard that. I did check it out and the error is the def it should be: .def("foo", (void(*)(bool, int, char))0, foo_overloads()); I fixed the docs and updated to CVS. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
On 8/31/06, Joel de Guzman <djowel@gmail.com> wrote:
Ok, disregard that. I did check it out and the error is the def it should be:
.def("foo", (void(*)(bool, int, char))0, foo_overloads());
I fixed the docs and updated to CVS.
Do you want to consider to fix "def"? .def("foo", foo_overloads() ); It is not clear why user should pass second argument. Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Roman Yakovenko wrote:
On 8/31/06, Joel de Guzman <djowel@gmail.com> wrote:
Ok, disregard that. I did check it out and the error is the def it should be:
.def("foo", (void(*)(bool, int, char))0, foo_overloads());
I fixed the docs and updated to CVS.
Do you want to consider to fix "def"?
.def("foo", foo_overloads() );
It is not clear why user should pass second argument.
I don't think it can be fixed. The compiler does not have enough information in there to know the exact signature needed. I may be wrong though, so I'll investigate. If you know how to implement this, I'm all ears. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel de Guzman <djowel@gmail.com> writes:
Roman Yakovenko wrote:
On 8/31/06, Joel de Guzman <djowel@gmail.com> wrote:
Ok, disregard that. I did check it out and the error is the def it should be:
.def("foo", (void(*)(bool, int, char))0, foo_overloads());
I fixed the docs and updated to CVS.
Do you want to consider to fix "def"?
.def("foo", foo_overloads() );
It is not clear why user should pass second argument.
I don't think it can be fixed. The compiler does not have enough information in there to know the exact signature needed. I may be wrong though, so I'll investigate. If you know how to implement this, I'm all ears.
I don't think you're wrong. -- Dave Abrahams Boost Consulting www.boost-consulting.com
On 9/12/06, David Abrahams <dave@boost-consulting.com> wrote:
Joel de Guzman <djowel@gmail.com> writes:
Roman Yakovenko wrote:
On 8/31/06, Joel de Guzman <djowel@gmail.com> wrote:
Ok, disregard that. I did check it out and the error is the def it should be:
.def("foo", (void(*)(bool, int, char))0, foo_overloads());
I fixed the docs and updated to CVS.
Do you want to consider to fix "def"?
.def("foo", foo_overloads() );
It is not clear why user should pass second argument.
I don't think it can be fixed. The compiler does not have enough information in there to know the exact signature needed. I may be wrong though, so I'll investigate. If you know how to implement this, I'm all ears.
I don't think you're wrong.
Actually my idea was simple: foo_overloads class derives from boost::python::detail::overloads_base class. I think you can use this fact and to remove the need to pass function signature to the "def". -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
"Roman Yakovenko" <roman.yakovenko@gmail.com> writes:
Actually my idea was simple: foo_overloads class derives from boost::python::detail::overloads_base class. I think you can use this fact and to remove the need to pass function signature to the "def".
How? We need to be able to access the argument types at compile-time. Anyway, if you think it can be done, please show us with actual working code, because I'm pretty sure it's impossible. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams -
Joel de Guzman -
Roman Yakovenko