String Mixins

Travis Boucher boucher.travis at gmail.com
Mon Nov 16 15:42:19 PST 2009


I've been playing with string mixins, and they are very powerful.

One thing I can't figure out is what exactly can and cannot be evaluated 
at compile time.

For example:

----
char[] myFunc1() {
	return "int a = 1;";
}

char[] myFunc2() {
	char[] myFunc3() {
		return "int b = 2;";
	}
	return myFunc3();
}

void main() {
	mixin(myFunc1());
	mixin(myFunc2());
}
----

myFunc1() can be used as a string mixin.
myFunc2() can't be.

I'm sure there are other things that I'll run into, but I figure there 
is some simple set of rules of what can and can't be used as a string mixin.



More information about the Digitalmars-d mailing list