Hello Denis,
1. auto t = new Thread ( { a=42 } );
or auto t = new Thread ( () { a=42 } );
It already works, just try it (but don't forget to put a semicolon at
the end).
2. array.findAll (arr, (item) { item.contains ("abc") } ); 3. foo (
(a, b) { a + b } );
4. array.findAll (arr, (item) { return item.contains ("abc"); } );
I'm not proposing this syntax (maybe I probably should, but I have
feeling I would not be first). It may not even be possible to parse
it, but seems to me more similar to how currently functions are
written. In this setting {exp} or {stm} is not *special* case.
I believe it would work. And yes, it was already proposed by many
others.
it works with two differences:
1. the semicolon is required, even if the body consist only of one expression.
This is a minor detail.
2. more importantly - parameter types must be specified explicitly. I don't
understand why type of b cannot be inferred in this example:
void foo (void delegate (int a) dg)
{
dg(1);
}
void main ()
{
foo ( (int b) { writeln (b); } );
}
Does the type inference has problem with template code or some other combination
of features...?