2 ms·
In order to make things work smoothly, the module has to have its own namespace, and a namespace that is closed. D also has an `alias` feature, where you can d
by WalterBright 1y ago
In order to make things work smoothly, the module has to have its own namespace, and a namespace that is closed.
D also has an `alias` feature, where you can do things like:
alias Q = abc.T;
where from then on, `abc.T` can be referred to simply as `Q`. This also eliminates a large chunk of purpose behind the preprocessor.
- fooker 1y agoNeat, closed namespaces sound great! C++ has adapted the ‘using’ keyword now to seem fairly similar to alias, but can’t completely subsume macros unfortunately.
- WalterBright 1y agoClosed namespaces means the module can be reliably imported anywhere without changing its semantic meaning.
- Gibbon1 1y agoI've really wanted that in C for a long time. It seems like a very trivial thing as well.
- WalterBright 1y agoYeah, it's actually easy to implement, too. It replaces the preprocesser: #define Q abc.T with hygiene. Once you get used to it, it has all kinds of nice uses.
- StilesCrisis 1y agoC++ code generally uses `using` for typedefs. Macro-based typedefs are exceptionally rare and frowned upon.