On Saturday, 11 January 2014 at 07:45:31 UTC, Casper Færgemand wrote:
Have:
enum (or is immutable array better?) array = ["derp", "lala"];

Want:
mixin("some syntax" ~ array[0]);
mixin("some syntax" ~ array[1]);

You can use template argument lists for indexable compile-time lists:

---
import std.typetuple : TypeTuple;

alias array = TypeTuple!("derp", "lala");

mixin("some syntax" ~ array[0]);
mixin("some syntax" ~ array[1]);
---

Basically, to specify a number of similar functions based on a list of strings. Why? Pegged's semantic actions allows only calling a function by name, not specifying parameters. I could probably ask for an extension, but if there's a cool template or whatever way to do this, it would be a lot nicer. :3

Your problem is probably better solved without string mixins, but we'd probably need to see some code or more elaboration to accurately suggest a solution.

Reply via email to