lambdas and function literals in classes

John Colvin john.loughran.colvin at gmail.com
Tue Jul 9 03:50:01 PDT 2013


JS asked about this in the main group, but here is more 
appropriate and I'm quite interested myself.

Can someone explain the rationale behind this:

class A
{
     auto a = (){}; 		//Lambda not allowed
     auto b = function(){};	//Function allowed
     auto c = delegate(){};	//Delegate not allowed
}

A guess:

Delegate's aren't allowed as members due their context pointer 
(why???), lambdas are assumed to be delegates unless they are 
proved to not need context (and dmd is sucking at proving that).


More information about the Digitalmars-d-learn mailing list