On 2017-08-15 15:09, Nicol Bolas wrote:
> On Tuesday, August 15, 2017 at 2:38:06 PM UTC-4, Matthew Woehlke wrote:
>> On 2017-08-12 10:25, Nicol Bolas wrote:
>>> That being said, it should be noted that much of the reason for pimpl
>>> will be made obsolete once we get modules.
>>
>> Does "much of the reason" include binary compatibility?
>
> If you mean that one library can change aspects of a class's implementation
> which are not reflected in its class definition without the consuming code
> having to be recompiled? The answer is yes.
>
> If you mean that one library can change private definitions of an interface
> class without the consuming code having to be recompiled? The answer is no.
>
> If you mean that the inevitable recompile from item 2 will be *far faster*
> due to not having to recompile the standard library, Boost, and every other
> thing that *wasn't* changed just because they're being included in a .cpp
> file that has to be recompiled? The answer is yes.
So... that would be a "no".
Why?
Let's take Qt, for example. Widely used; lots of consumers. Uses PIMPL
to ensure BC. This means that Qt is updated... I can just update Qt, and
(hopefully) nothing breaks.
If Qt wasn't using PIMPL, then I would need to recompile *my entire
desktop environment* (that's on the order of 50-100 libraries and
applications). Actually, it's worse, because *I* am not recompiling
them. The recompile (which may in fact be much faster) happens on some
build farm. The cost *I* pay — which *everyone* pays — is in downloading
and installing all those updates. Modules won't affect those costs.
...which is why Qt uses PIMPL, and will continue to use PIMPL even
post-modules.
I'm not even convinced that modules are a reason to stop using PIMPL, or
other dependency-reducing techniques. Recompiling "much faster" still
doesn't beat "not needed", even in the quantitative sense, never mind
the qualitative difference (especially in the case of libraries with
external consumers)...
That was my main intent. To reduce boilerplate code as depending on how complicated your class is, using pimpl is even more complicated and easy to get wrong and introduce bugs/leaks.
I did/do not wish to extend this idea further as there are still quite a few other papers in flight that could affect this both for the good and the bad. So for now this was just to post and get feedback to help me design and write a proposal that covers everyone's points here where possible.