Fellow ChucKists,<br><br>A new year (at least on the Roman calendar). Us ChucKists should feel especially good about this one as the Roman calendar had a leap second this year; I don&#39;t think the rest of the universe is as strongly timed as we are.<br>
<br>Anyway, a brand new year and brand new bugs, starting with one of mine. Consider this fragment;<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
&nbsp; &nbsp;//========member functions=====================
<br>
&nbsp; &nbsp;
<br>
&nbsp; &nbsp;//sets time to average the input freq over.
<br>
&nbsp; &nbsp;//reaction speed v.s. accuracy
<br>
&nbsp; &nbsp;fun dur avgTime( dur length)
<br>
&nbsp; &nbsp;&nbsp; &nbsp;{
<br>
&nbsp; &nbsp;&nbsp; &nbsp;if (length &lt; samp)
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;&lt;&lt;&quot;warning, duration too short, correcting&quot;&gt;&gt;&gt;;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;ms =&gt; d.delay;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}
<br>
&nbsp; &nbsp;&nbsp; &nbsp;if (length &gt; d.max())
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;&lt;&lt;&quot;warning, duration too long, correcting&quot;&gt;&gt;&gt;;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;d.max() =&gt; d.delay;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}
<br>
&nbsp; &nbsp;&nbsp; &nbsp;else length =&gt; d.delay;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;.5 * (second / d.delay() ) =&gt; avg.gain;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;
<br>
&nbsp; &nbsp;&nbsp; &nbsp;return d.delay();
<br>
&nbsp; &nbsp;&nbsp; &nbsp;}
<br>
&nbsp; &nbsp;//returns this time&nbsp; &nbsp;
<br>
&nbsp; &nbsp;fun dur avgTime( dur length)
<br>
&nbsp; &nbsp;&nbsp; &nbsp;{
<br>
&nbsp; &nbsp;&nbsp; &nbsp;return d.delay();
<br>
&nbsp; &nbsp;&nbsp; &nbsp;}
<br><br>
</blockquote></div><br>Note that the second version shouldn&#39;t have the &quot;dur length&quot; parameter, it should be overloaded to get the averaging period, which might be useful at times, for example to make sure that this period isn&#39;t too short compared to the frequency we are getting. My fault; I was too hasty in my enthusiasm. Considder updating your files if you added this to a collection of useful code fragments.<br>
<br>More generally; this means that we can apparently have overloaded functions that take the same argument(s) within the same scope. I don&#39;t think that&#39;s correct behaviour; this could lead to a lot of confusion and I can&#39;t think of a single instance where it would be beneficial. To make it more clear without any class being involved;<br>
<br>//--------------<br>//this will parse and run;<br>fun int foo (int bar)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; return false;<br>&nbsp;&nbsp;&nbsp; }<br><br>//this one is just silly, in fact it won&#39;t even be called, the top one has priority<br>fun int foo (int bar)<br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; return true;<br>&nbsp;&nbsp;&nbsp; }<br>//-------------<br><br>Now; &quot;powertools can maim&quot; and I don&#39;t mean to blame ChucK for a silly mistake that *I* made but do we really have a need to be able to have those two functions within the same scope? Can anybody think of a single instance where this could be useful at all? There are/were other instances where the overloading of functions wasn&#39;t propperly checked (particularly with regard to return types) which could/can lead to crashes. I feel it should be considdered to check for this as well when checks for that situation are added to the parser, even if this type of thing doesn&#39;t crash as such.<br>
<br>Yours,<br>Kas.<br>