Create mixins from a list of strings
Casper Færgemand" <shorttail at hotmail.com>
Casper Færgemand" <shorttail at hotmail.com>
Sat Jan 11 17:29:30 PST 2014
On Saturday, 11 January 2014 at 16:07:30 UTC, Philippe Sigaud
wrote:
> I'm a bit leery of putting D call syntax into semantic actions,
> because it'll also explode the Pegged grammar size (I'm fairly
> sure
> I'd have to pull in a big part of D if I want to get function
> calls
> right). That's one feature I wanted at one time, but I'm not
> sure it's
> a good idea.
Yes, and I would not be able to argue this is the definite way to
handle things anyway. It's a try at type checking with little
regard to efficiency. I'm just happy it works with Timon Gehr's
extremely simple solution. :3
On Saturday, 11 January 2014 at 20:52:15 UTC, Timon Gehr wrote:
> import std.string, std.algorithm;
>
> enum semanticArray = ["derp", "lala"];
>
> mixin(semanticArray.map!(a=>`T `~a~`(T)(T t) {
> t.name ~= "`~a~`";
> return t;
> }`).join());
Here, have a heart. <3
More information about the Digitalmars-d-learn
mailing list