auto functions not authorized inside main?

Rory McGuire rmcguire at neonova.co.za
Mon Jun 28 06:40:14 PDT 2010


On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud  
<philippe.sigaud at gmail.com> wrote:

> Is it defined somewhere that auto functions are not authorized inside  
> main?
>
> void main()
> {
>     auto fun(string s) { return s;} // this does not compile
> }
>
> error:
>
> main.d|6|found 's' when expecting ')'|
> main.d|6|semicolon expected, not ')'|
> main.d|6|found ')' instead of statement|
> main.d|7|unrecognized declaration|
> ||=== Build finished: 4 errors, 0 warnings ===|
>
>
> So it's not even parsed?
>
> I couldn't find a bugzilla entry for this and I cannot believe no one  
> ever
> tried to put an auto fun inside main!
>
> Is that part of the spec?
>
> Philippe

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;};



-Rory


More information about the Digitalmars-d-learn mailing list