auto functions not authorized inside main?

Rory McGuire rmcguire at neonova.co.za
Mon Jun 28 11:06:46 PDT 2010


On Mon, 28 Jun 2010 16:01:46 +0200, BCS <none at anon.com> wrote:

> Hello Rory,
>
>> On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud
>> <philippe.sigaud at gmail.com> wrote:
>>
>>> void main()
>>> {
>>> auto fun(string s) { return s;} // this does not compile
>>> }
>>
>> Hope this isn't a stupid question, but how would you access this
>> function
>> if it did work?
>> Would it be fun("asdf")?
>> Is this just shorthand for:
>> auto fun = function(string s) {return s;};
>
> I would look almost the same to the user but should in fact be a normal  
> local function.
>

Ye I got it now.

My brain was interpreting it as a delegate that wasn't being assigned to  
anything for some reason.

Now I get that it is just return type inferance doesn't work for inner  
functions.

-Rory


More information about the Digitalmars-d-learn mailing list