blocks with attributes vs inlined lambda
monarch_dodra
monarchdodra at gmail.com
Sat Jun 8 07:57:16 PDT 2013
EDIT: Sorry: stupid computer sent before I was finished. I was
saying...
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 //declaration
{ //body
//code here can't throw
} () //actual call
//More code
}
--------
This works. This feature is appearing with higher frequency
inside phobos, which is proof it is a good feature, and that it
has uses, and is becoming popular.
My beef though is that the syntax is a bit opaque, and not really
idiomatic. It looks more like a hacker's trick than a real
language feature. It's not something you'd do "naturally". At
least, I know a beginner may not feal comfortable with this.
Given that users are now actually doing this, that we have proof
it works and is a useful feature, shouldn't we push to have
actual blocks with attributes in the language?
I think we should... Thoughts?
More information about the Digitalmars-d
mailing list