blocks with attributes vs inlined lambda

monarch_dodra monarchdodra at gmail.com
Sat Jun 8 07:52:22 PDT 2013


I remember think that being able to mark specific parts of code 
with certain attributes, inside a block, could be very useful.

for example:

--------
void foo()
{
    //Code

    /Critical section
    nothrow {
        //code here can't throw
    }

    //More code
}
--------

I have since learned that you can do this with lambda's instead, 
declaring and calling them in a single line:

--------
void foo()
{
    //Code

    /Critical section
    () nothrow
{
        //code here can't throw
    }

    //More code
}
--------


More information about the Digitalmars-d mailing list