Robert;<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>
Did you spot the difference?  &quot;bad_pre_constructor&quot; is declared (improperly) to return a float, but it doesn&#39;t, and an instantiation of Foo silently returns a null.  &quot;good_pre_constructor&quot; is properly declared with a void return, and an instantiation of Foo returns a good value.<br>

</blockquote><div><br>Ah, yes. I think this has been under debate before; functions that claim they will return something must return this and ChucK doesn&#39;t verify that it does. I think it was debated in some depth on the forum. Part of the problem is that it&#39;s not clear ChucK could know a function will always return when we do know this. Consider this;<br>
<br>fun int invert (int input)<br>  {<br>  if (input == 0) return true;<br>  else if (input == 1) return false;<br>  }<br><br>We may know that this function will only get fed a 1 or a 0 and so it may be &quot;safe&quot; but if it would get a 3 then there will be a issue. While this may be ok in certain contexts I&#39;d always re-write it like this;<br>
<br>fun int invert (int input)<br>
  {<br>
  if (input == 0) return true;<br>
  else return false;<br>
  }<br><br>What we could do is require a function of a non-void type to have a &quot;return&quot; statement somewhere in it, maybe even require that it should be on the last line and outside of any conditions and issue a complaint otherwise, but that will outlaw some types of functions that may be perfectly fine. I&#39;m a bit scared that rules that will prevent improper functions from being written at all will also stifle creativity; in many cases us programmers are a lot more clever than parsers are. That said; I think it&#39;s good form to always end functions of a non-void type with a return statement, even if it&#39;s just &quot;else return false&quot;, often I will make it print a warning if it fails in such a way due to unexpected input.<br>
<br>Some people insist on only having a single return statement on the last line. While that&#39;s very safe I feel it can lead to overly complicated constructs that I don&#39;t find as pleasant to read or write and that proper indentation and syntax highlighting can make it clear other strategies are safe as well; the second example I gave above does that and I consider that one quite natural and readable as well as clearly safe.<br>
<br>The only reason I can think of -right now- to not have a return statement on the last line and outside of any conditions is when we would want to kill the whole shred on that line. While strictly speaking this is valid and might be useful that&#39;s far from clean and will likely lead to readability issues but is that really a reason to ban such tricks? I mean; maybe our foot is rebelling against us, we may have a valid reason for shooting it ;¬).<br>
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This is not friendly behavior.<br>
</blockquote><div><br>I agree, but it&#39;s not clear what proper behaviour should be either. For now I&#39;m inclined to have compilation halt if the &quot;return&quot; keyword isn&#39;t used in a function that is of a non-void type and leave the programmer to make sure it will return in each and every case. That would at least catch simple typos in the definition of the function type and give a fair warning. <br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
P.S.: Uh, is this the right forum for reporting bugs like this?<br></blockquote><div><br>Absolutely. It&#39;s interesting that you found that this issue (which in itself was known) will prevent object instantiation as well. I agree with you that the current behaviour can lead to lengthy searches due to only making a single typo.<br>
</div></div><br>Yours,<br>Kas.<br>