<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD></HEAD>
<BODY style="font-family:'DejaVu Sans Mono'; font-size:12px"><DIV>On Mon, 28 Jun 2010 16:07:43 +0200, Philippe Sigaud &lt;philippe.sigaud@gmail.com&gt; wrote:<BR><BR><BLOCKQUOTE style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><DIV class="gmail_quote">On Mon, Jun 28, 2010 at 15:40, Rory McGuire <SPAN dir="ltr">&lt;<A href="mailto:rmcguire@neonova.co.za">rmcguire@neonova.co.za</A>&gt;</SPAN> wrote:<BR><BLOCKQUOTE class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<DIV><DIV class="h5"><BR><BLOCKQUOTE class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
void main()<BR>
{<BR>
    auto fun(string s) { return s;} // this does not compile<BR>
}<BR><BR></BLOCKQUOTE>
<BR></DIV></DIV>
Hope this isn't a stupid question, but how would you access this function if it did work?<BR>
Would it be fun("asdf")?<BR></BLOCKQUOTE><DIV><BR>Yes, that's what I had in mind. Basically, just using it as any other auto inner function. <BR><BR>void main()<BR>{<BR>auto fun(string s) { return s;}<BR>auto s = fun("abc");<BR>
auto t = fun("def");<BR>}<BR> <BR></DIV><BLOCKQUOTE class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Is this just shorthand for:<BR>
auto fun = function(string s) {return s;};</BLOCKQUOTE><DIV><BR>That'd be about the same, yes. Fact is, I don't really _need_ this, I was just astonished to be bitten by this.<BR>Why can I do<BR>
<BR>void main()<BR>{<BR>    string foo(string s) { return s;}<BR>}<BR><BR>and not<BR><BR>void main()<BR>{<BR>    auto foo(string s) { return s;}<BR>} <BR><BR>?<BR><BR>***<BR><BR>OK, I tested it some more, and it seems you cannot define auto function inside any other function. So auto function cannot be inner functions. I'm quite astonished I never did that when using D, but OK.<BR>
<BR>I filed a bug report, at least to update the docs. It's bug #4401.<BR><BR><BR>Philippe<BR><BR><BR><BR></DIV></DIV>
</BLOCKQUOTE><BR>Right! I get what you're saying, didn't realise because it was formatted more how I would format a anon delegate.</DIV><DIV>You're saying "surely the compiler can infer the return type for a inner function just as much as it can infer the return type of a normal function..<BR></DIV><DIV><BR></DIV><DIV>Must be a compiler bug.</DIV><DIV><BR></DIV><DIV>-Rory</DIV></BODY></HTML>