blocks with attributes vs inlined lambda
deadalnix
deadalnix at gmail.com
Sat Jun 8 09:21:25 PDT 2013
On Saturday, 8 June 2013 at 16:13:28 UTC, monarch_dodra wrote:
> On Saturday, 8 June 2013 at 15:56:47 UTC, deadalnix wrote:
>>
>> Sound like a nice idiom. Why is the first set of () needed ?
>> Can we change the grammar to remove them ?
>
> It's because you are actually declaring a lambda that takes no
> arguments, and has no name, and contains a body. BTW, you
> quoted my incomplete code, the correct code I wanted to post
> was:
>
> () nothrow {//anonymous lambade declaration
> //Body of the lambde
> }() //actual call to lambda
>
> I'd want to be able to do this, without either the first or
> last set of (). The required change of grammar would mean
> there'd be no lambda at all afterwards.
{} is a lambda already. The first set of () is optional.
More information about the Digitalmars-d
mailing list