Lambda syntax, etc
bearophile
bearophileHUGS at lycos.com
Mon Feb 9 06:11:46 PST 2009
Jarrett Billingsley:
> auto r = find!(\a -> a.Weight > 100)(range);
> [...]
>
> something(\a, b
> {
> stmt1;
> stmt2;
> });
This looks better to me (but I don't know if this is the best syntax, it's just an idea):
// syntax for lambda that contains a single expression, implicit return (this is the most common case):
auto r = find!(a => a.Weight > 100)(range);
// syntax for lambda that contains one or more statements, no return, side effects only:
something({ a, b :: stmt1; stmt2; });
// syntax for lambda that contains one or more statements, with side effects and return:
something({ a, b :: stmt1; return foo(); });
Bye,
bearophile
More information about the Digitalmars-d
mailing list