Intention revealing #include ?

In a previous post I described how C and C++ have a third #include mechanism. It occurs to me that this idea has possibilities beyond simply using LOCAL(header) as a synonym for "header" and SYSTEM(header) as a synonym for <header> and then using the resulting seam to gain some leverage for testing. You could also add intention revealing names. For example, something like this:

#include "dice_thrower.hpp"
#include <vector>

class stub_dice_thrower : public dice_thrower
{
...
private:
    std::vector<int> stubbed;
};

could be written like this:

#include REALIZES(dice_thrower.hpp)
#include COMPOSES(vector)

class stub_dice_thrower : public dice_thrower
{
...
private:
    std::vector<int> stubbed;
};

Caveat emptor: I don't have any actual examples of this in real code. It's just an idea. It feels a bit like a solution looking for a problem. But I thought I would mention the idea here to see if anyone thinks it has any legs...

No comments:

Post a Comment