|
 |
Actually, one place I think C++ style templates beat out generics is in this:
In MS's simple game libraries, there's a class called GameComponent.
It inherits from IUpdatable, IDrawable, and IMumble, each of which provides
the declaration of one of the main routines in a game (update, draw, and
initialize, respectively).
Now, if I wanted (and I do) to make a collection of things that act like
GameComponent objects but aren't necessarily game components, I don't think
I can do that in C#. I would have to have a collection parameterized on all
three of those interfaces. GameComponent supports a bunch of things that i
might not want to have to support, but I can't make a collection that'll let
me add "anything with those three routines, including GameComponent."
I think this is something that Google's Go did better, if I understand it.
C++ templates don't have that problem, but that's because you don't compile
them separately, so what would normally have to be a runtime check gets done
at compile time.
In any case, it's rather annoying. :-) I might have to figure out how to
patch up MS's samples to also host a collection of game components as well
as the scene-activation/deactivation they do.
--
Darren New, San Diego CA, USA (PST)
Yes, we're traveling together,
but to different destinations.
Post a reply to this message
|
 |