Jacob Krieg
Jacob Krieg

Reputation: 3174

What does "d" stand for in d-pointer?

Qt makes heavy use of the PIMPL idiom in their development process: https://wiki.qt.io/D-Pointer

As I've read here: "The name 'd-pointer' stems from Trolltech's Arnt Gulbrandsen, who first introduced the technique into Qt, making it one of the first C++ GUI libraries to maintain binary compatibility even between bigger release.". But nobody says what "D" stands for.

So what does the "D" stand for in D-Pointer?

Upvotes: 13

Views: 1845

Answers (2)

arnt
arnt

Reputation: 9685

I'll add my own answer, since I remember the day it happened.

I was trying to extend something while maintaining binary compatibility, and noticed that there was a pointer called 'data' that I could reuse for a different purpose. So I made a private class for implementation-related data (a pimpl), put both the old data and my new data there, and since the existing name seemed to fit I kept the name.

I abbreviated it from data to d after a short meeting later on the same day, where we agreed that the pattern I'd invented stumbled upon was good and we should use it widely, and that d-> was short enough and unique enough to be used everwhere as a mark of implementation-specific fields.

At the same meeting, we decided to put implementation-specific data in d-> as a matter of policy from then on, mostly in order to keep the number of includes down, but also to keep the declared API clean in general. Fewer private variables in the class declaration means few opportunities for error, fewer temptations, fewer things that can conflict with subclass naming and so on. Better hygiene.

Upvotes: 10

Amadeus
Amadeus

Reputation: 10665

From this page Data Sharing with Class (an old docs from QT), it says:

Before we can share an object's private data, we must separate its interface from the private data using an idiom called "d-pointer" (data pointer)

So, d-pointer means data-pointer

Upvotes: 14

Related Questions