String Mixins

Justin Johansson no at spam.com
Mon Nov 16 23:21:23 PST 2009


Travis Boucher wrote:
> 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.

Hi Travis,

I've only been 'round here for a few months myself and often find myself
in need of answers to such questions.  I believe, though, that this is 
the sort of question that the group prefers to have asked on D.learn.
That's also a better forum for other newbies to find answers as well.

Regards,
Justin Johansson



More information about the Digitalmars-d mailing list