|
|
|
|
|
by gmueckl
2050 days ago
|
|
Module parameterization by type is a kind of a big deal. This enables reuse and composability opportunities that can become pretty impressive. C++ templates can be used in a similar way, but it's not perfect. The closest match I can think of is a template class with static members. D has one more mechanism that is conceptually very different, but could be used to express somewhat similar patterns: template mixins. These are best described as parameterized template sections of code worh one or more declarations that have to be reasonably well formed on their own and are virtually pasted into the code at the location where they are instantiated. They exist somewhere in the space between templates and C preprocessor macros. |
|