Bug or not? "Functions cannot return a function"

Meta via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 16 18:14:43 PST 2016


On Thursday, 17 November 2016 at 01:48:51 UTC, Jonathan M Davis 
wrote:
> Well, you _can't_ return a function. You could return a 
> function pointer or a delegate, but not a function. What would 
> it even mean to return a function?

Well, it works. This compiles:

auto bug(alias f)()
{
     return f;
}

void fun() {}

void main()
{
	bug!fun(); //Error: functions cannot return a function
}

So why can't I return cast(typeof(f))&f? Furthermore, it gives me 
the exact same error when I change it to `return *&f`.


More information about the Digitalmars-d mailing list