Special Code String for mixins
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Wed Mar 15 11:55:55 PDT 2017
On Wed, Mar 15, 2017 at 01:50:28PM +0000, Inquie via Digitalmars-d wrote:
> I hate building code strings for string mixins as it's very ugly and seems
> like a complete hack.
>
> 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).
Have you looked up token string literals?
enum myCode = q{
// This is actually a string that looks like code
void func() { }
// Of course it allows token sequences that aren't valid
// D, but that's not important because mixin() will
// complain if it's malformed.
float void is double null {[ 0* }]
};
T
--
Not all rumours are as misleading as this one.
More information about the Digitalmars-d
mailing list