<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi, all. So I'm trying to make some very ugly code generic. The main
    ugliness isn't in the code shape, it's in the running time. It's
    O(n^m) Eww! (don't worry, n is only about 6.)<br>
    <br>
    Anyhoo, Here's what I want:<br>
    <br>
    <blockquote>void foo(int size)(int[] arr){<br>
          mixin(forStart!(size));<br>
              doStuff(pos0, pos1, pos2,...); // this line is generated
      by another mixin that works correctly. <br>
      }<br>
      <br>
      //Generates for loop headers. <br>
      private static string forStart( int sz)(){<br>
          string forStrings = "";<br>
          for(int i = 0; i < sz; i++){<br>
              forStrings ~="foreach(pos"~text(i)~"; 0..arr.length)\n ";<br>
          }<br>
          return forStrings;<br>
      }<br>
      <br>
    </blockquote>
    It is my great displeasure to report: <br>
    src\hw06.d(35): found 'EOF' instead of statement<br>
    src\hw06.d(18): Error: template instance hw06.tryCombinations!(5)
    error instantiating<br>
    <br>
    But here's the wacky part: <br>
    I can execute this function and print it to stdout. If I do, I
    get...<br>
    foreach(pos0; 0..arr.length)<br>
    foreach(pos1; 0..arr.length)<br>
    foreach(pos2; 0..arr.length)<br>
    foreach(pos3; 0..arr.length)<br>
    foreach(pos4; 0..arr.length)<br>
    <br>
    and I can copy-paste this exact code into where I currently have the
    mixin, and the code behaves correctly. <br>
    <br>
    Is there some subtle aspect of mixin that I'm missing here? <br>
    <br>
    Cheers,<br>
    Charles.<br>
  </body>
</html>