Templates everywhere
Bane
branimir.milosavljevic at gmail.com
Sun Mar 14 18:32:22 PDT 2010
> ======= C++ =========
> template<class T> class Foo
> {
> T member;
> };
> ======= D ===========
> class Foo(T)
> {
> T member;
> }
> =====================
>
> Yes, it looks like a trivial change, and perhaps it is. But it makes a
> world of difference, because it now looks like something I do get - a
> parameter list to something.
Fucking beautiful. I finally get it.
> I had another epiphany from watching Scott Meyers give a presentation
> about an application for templated type lists in C++. Nearly the full
> hour was spent detailing a titanic struggle with the syntax. I suddenly
> realized that the whole presentation would have been over in 5 minutes
> if the syntax of type lists was simply that of an array of types. We
> already understand arrays of values, so why should an array of types be
> any different?
>
> It isn't the concept or application of templates that is hard. It's the
> C++ syntax for them that's hard. It's hard in C++ because when they were
> designed, little was known or understood about what templates were good
> for and how they should be used. Now that we do know, we can make a much
> more straightforward design.
They say you understand stuff only after you make it, not before.
More information about the Digitalmars-d
mailing list