On Wednesday, 15 March 2017 at 14:12:57 UTC, Adam D. Ruppe wrote:
On Wednesday, 15 March 2017 at 13:50:28 UTC, Inquie wrote:
I hate building code strings for string mixins as it's very ugly and seems like a complete hack.

Me too, that's why I avoid doing it.

Check out my tips of the week here:
http://arsdnet.net/this-week-in-d/sep-20.html

and here:
http://arsdnet.net/this-week-in-d/2016-feb-21.html

for some ways I minimize them.

How bout, instead, we have a special code string similar to a multiline string that allows us to represent valid D code. The compiler can then verify the string after compilation to make sure it is valid D code(since it ultimately is a compile time constant).

Are you familiar with D's `q{ ... }` literals? They are lexed though not parsed.

enum code1 = q{
   void happyCode = "Makes me @@s@@";
};

then you'd have to do the `.replace("@@s@@", whatever)` yourself on it though. They also do not allow unbalanced { }.


It is typed as string btw, no special type, just like if you used regular quotes, just looks nicer at the definition.

Visual D doesn't seem to do much. Maybe it is lexed but most of the code is a solid purple. Better than a normal string.

I was hoping to get something parsed though to find based errors a CT in a meaningful way(line numbers, etc).

Reply via email to