blocks with attributes vs inlined lambda
monarch_dodra
monarchdodra at gmail.com
Sat Jun 8 10:30:49 PDT 2013
On Saturday, 8 June 2013 at 17:27:48 UTC, monarch_dodra wrote:
> On Saturday, 8 June 2013 at 16:21:26 UTC, deadalnix wrote:
>>
>> {} is a lambda already. The first set of () is optional.
>
> Oh Yeah. Didn't know that. You learn something new every day.
>
> ...but for that to work, (it seems) you have actually store or
> pass the lambda, or all the parser sees is a plain "block".
Improved example:
-------
void main()
{
int i;
auto y = {++i;}; //lambde (not called)
{++i;}; //simple block
(){++i;}(); //inline lambda call
// {++i;}(); //Un-recognized
writeln(i); //prints 2
}
-------
More information about the Digitalmars-d
mailing list