<div>I'm writing a function called <font class="Apple-style-span" face="'courier new', monospace">genArray</font> that accepts a function <font class="Apple-style-span" face="'courier new', monospace">gen</font> and returns a random array populated by calling <font class="Apple-style-span" face="'courier new', monospace">gen()</font>. genString builds on this by returning <font class="Apple-style-span" face="'courier new', monospace">genArray(&genChar)</font>. But my type signatures are wrong.</div>

<div><br></div><div>In dashcheck.d:</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">char genChar() {</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    return cast(char) uniform(0, 128);</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">}</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">T[] genArray(T function() gen) {</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    int len = uniform(0, 100);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    T[] arr = [];</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    for(int i = 0; i < len; i++) {</font></div><div>

<font class="Apple-style-span" face="'courier new', monospace">        arr ~= gen();</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    }</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>

</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    return arr;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">}</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>

</font></div><div><font class="Apple-style-span" face="'courier new', monospace">string genString() {</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    return genArray(&genChar);</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">}</font></div><div><br></div><div>Trace:</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">dashcheck.d(17): Error: undefined identifier T</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">dashcheck.d(17): Error: T is used as a type</font></div><div><font class="Apple-style-span" face="'courier new', monospace">dashcheck.d(17): Error: undefined identifier T</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">dashcheck.d(17): Error: T is used as a type</font></div><div><br></div><div>Full code at <a href="https://github.com/mcandre/dashcheck">GitHub</a></div>

<div><br></div>Cheers,<div><br></div><div>Andrew Pennebaker</div><div><a href="http://www.yellosoft.us" target="_blank">www.yellosoft.us</a></div>