Special Code String for mixins

Nick Sabalausky (Abscissa) via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 15 08:39:38 PDT 2017


On 03/15/2017 09:50 AM, Inquie wrote:
>
> e.g.,
>
> string s = "smile";
> enum code1 = @#
> void happyCode = "Makes me @@s@@";
> #@
>
> enum code2 = code1 ~ @#
> int ImThisHappy = @@s.length@@;
> #@
>
> mixin(code);
>

import scriptlike; // https://github.com/Abscissa/scriptlike

string s = "smile";

// http://semitwist.com/scriptlike/scriptlike/core/interp.html
enum code1 = mixin(interp!q{
void happyCode = "Makes me ${s}";
});

enum code2 = code1 ~ mixin(interp!q{
int ImThisHappy = ${s.length};
});

mixin(code2);

Wish I could get rid of the need for "mixin(...)" in interp though.



More information about the Digitalmars-d mailing list