Attn: Maintainer of boost/bind.hpp

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Attn: Maintainer of boost/bind.hpp

Boost - Dev mailing list
In boost/bind.hpp there is injection of a boost namespace contents into
the global namespace:

```c++
#include <boost/bind/bind.hpp>

#ifndef BOOST_BIND_NO_PLACEHOLDERS

#if defined(BOOST_CLANG)
# pragma clang diagnostic push
# if  __has_warning("-Wheader-hygiene")
#  pragma clang diagnostic ignored "-Wheader-hygiene"
# endif
#endif

using namespace boost::placeholders;

#if defined(BOOST_CLANG)
# pragma clang diagnostic pop
#endif

#endif // #ifndef BOOST_BIND_NO_PLACEHOLDERS
```

The fact that Boost actually disables the relevant compiler warning
makes this particularly insidious.

No modern C++ library should ever do "using namespace" into the global
namespace in its public headers. Please fix this in the next release of
Boost.

Niall

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Attn: Maintainer of boost/bind.hpp

Boost - Dev mailing list
Niall Douglas wrote:

> In boost/bind.hpp there is injection of a boost namespace contents into
> the global namespace:

Including <boost/bind/bind.hpp> doesn't bring the placeholders into the
global namespace; if you don't want them there, just include
<boost/bind/bind.hpp>. <boost/bind.hpp> does for backward compatibility.

> Please fix this in the next release of Boost.

Breaking code without any warning is not a good practice, but I'll mark
<boost/bind.hpp> as deprecated to allow people time to migrate.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Attn: Maintainer of boost/bind.hpp

Boost - Dev mailing list
>> In boost/bind.hpp there is injection of a boost namespace contents
>> into the global namespace:
>
> Including <boost/bind/bind.hpp> doesn't bring the placeholders into the
> global namespace; if you don't want them there, just include
> <boost/bind/bind.hpp>. <boost/bind.hpp> does for backward compatibility.

Unfortunately, some of the Boost libraries include <boost/bind.hpp>, and
thus pollute the global namespace.

>> Please fix this in the next release of Boost.
>
> Breaking code without any warning is not a good practice, but I'll mark
> <boost/bind.hpp> as deprecated to allow people time to migrate.

Personally speaking, I think the macro `BOOST_BIND_NO_PLACEHOLDERS`
needs to become `BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS`. People can
still use <boost/bind.hpp>, but they'll need to explicitly opt into the
old behaviour.

(This will also encourage the maintainers of those libraries depending
on global placeholders to fix their libraries)

Niall

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Attn: Maintainer of boost/bind.hpp

Boost - Dev mailing list
Niall Douglas wrote:
> > Breaking code without any warning is not a good practice, but I'll mark
> > <boost/bind.hpp> as deprecated to allow people time to migrate.
>
> Personally speaking, I think the macro `BOOST_BIND_NO_PLACEHOLDERS` needs
> to become `BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS`. People can still use
> <boost/bind.hpp>, but they'll need to explicitly opt into the old
> behaviour.

That's true in principle, and will be my next step, at some point.

But what's also true is that people don't appreciate their code - that has
worked for decades - to be broken. Just grep for <boost/bind.hpp> within
Boost, and extrapolate.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Attn: Maintainer of boost/bind.hpp

Boost - Dev mailing list
On 13/12/2019 17:58, Peter Dimov via Boost wrote:

> Niall Douglas wrote:
>> > Breaking code without any warning is not a good practice, but I'll
>> mark > <boost/bind.hpp> as deprecated to allow people time to migrate.
>>
>> Personally speaking, I think the macro `BOOST_BIND_NO_PLACEHOLDERS`
>> needs to become `BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS`. People can
>> still use <boost/bind.hpp>, but they'll need to explicitly opt into
>> the old behaviour.
>
> That's true in principle, and will be my next step, at some point.
>
> But what's also true is that people don't appreciate their code - that
> has worked for decades - to be broken. Just grep for <boost/bind.hpp>
> within Boost, and extrapolate.

Ok, how about this:

1. Both `BOOST_BIND_NO_PLACEHOLDERS` and
`BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS` have the effect on placeholders
injection.

2. The deprecation message says something like "In Boost v1.XX, the
macro BOOST_BIND_NO_PLACEHOLDERS shall cease to have effect, and the
macro BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS will default to undefined.
This will cause ::placeholders to no longer be injected into the global
namespace by default. Please stop using <boost/bind.hpp>, or define
BOOST_BIND_ENABLE_GLOBAL_PLACEHOLDERS to suppress this message.".

How about Boost v1.76 as the switch over point? That's a year's notice.

Niall

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost