class templates and static if

James Miller james at aatch.net
Sun Feb 26 17:16:58 PST 2012


> Also, 'static' on the enum declaration doesn't really do anything. :)

but what if the immutable data changes?! :P

But yeah, D's type inference is reasonably good (not as good as
Haskell's, but nothing is as good as Haskell's), so doing what seems
like the best way is normally the right way around it.

If you have a lot of shared code, it might make more sense to just use
traditional subclassing. Assuming that the shared code is all mostly
Parser stuff then subclassing a Parser type into Request and Response
types makes more sense. You can easily add common functionality to the
base class, then add specific functionality to the individual classes.
It also allows for more reflection, which is easier and probably more
powerful than conditional compilation.

--
James Miller


More information about the Digitalmars-d-learn mailing list