On Sat, Jun 21, 2014 at 4:24 PM, Dicebot via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:
> On Saturday, 21 June 2014 at 13:45:14 UTC, Philippe Sigaud via
> Digitalmars-d-learn wrote:
>>
>> Out of curiosity, why use a mixin template containing a string mixin
>> instead of, well, directly injecting a string mixin in your struct,
>> with a function?
>
>
> Hiding non-hygienic implementation behind a more reliable interface.

In what way is a template more reliable than the equivalent function?
That's an honest question: I'm just looking at the code a few posts
upward:

mixin template Function(string name) {
    mixin("public static int " ~ name ~ "() { return other.module." ~
name ~"; }");
}

struct S {
      mixin Function!"fctn1";
}

And this double-mixin construction seems needlessly complicated to me,
compared to:

string Function(string name) {
      return "public static int " ~ name ~ "() { return other.module."
~ name ~"; }";
}

struct S {
    mixin(Function("fctn1"));
}

Reply via email to