Composing features at compile time

Jacob Carlborg doob at me.com
Sun Nov 24 11:54:27 PST 2013


On 2013-11-24 19:28, Dejan Lekic wrote:

> Jakob, whenever I need something like you describe, I do more/less the same what
> is described on this Wikipedia page:
> http://en.wikipedia.org/wiki/Composition_over_inheritance . C# example is
> exactly how I do this (in Java and D).

Unfortunately this looks like it works best when providing fairly 
separate features that doesn't interact with each other or the main 
functionality.

Perhaps I should describe the real usage I have for this. I'm trying to 
figure out a good way to make std.serialization more composeable without 
any overhead for unwanted features. One example is this function:

http://pastebin.com/XYGtTarn

Lines 19-25, 34-37 and 42 are only needed if pointers are supported.
Lines 27-30 are only needed if references are supported.

There are already both a couple of static-ifs and regular ifs. Adding 
even more static-ifs will make the code a bigger mess than it already is.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list