digitalmars.D - Re: Lambda syntax, etc
- Kagamin <spam here.lot> Feb 10 2009
- bearophile <bearophileHUGS lycos.com> Feb 10 2009
- Kagamin <spam here.lot> Feb 10 2009
- Kagamin <spam here.lot> Feb 10 2009
- bearophile <bearophileHUGS lycos.com> Feb 10 2009
grauzone Wrote:// syntax for lambda that contains a single expression, implicit return (this is the most common case): auto r = find!(a => a.Weight > 100)(range);
I really like this one, but I'd prefer something like > auto r = find(range, {a -> a.Weight > 100}); Note the -> instead of the =>, to avoid any ambiguities with the comparison operator.
auto r = find(range, {a -> a.Weight <- 100}); :)
Feb 10 2009
Kagamin:auto r = find(range, {a -> a.Weight <- 100});
Take a look at how the Fortress language manages spaces inside expressions. It can find a syntax error there, because the spacing is misleading. Bye, bearophile
Feb 10 2009
bearophile Wrote:Kagamin:auto r = find(range, {a -> a.Weight <- 100});
Take a look at how the Fortress language manages spaces inside expressions. It can find a syntax error there, because the spacing is misleading.
There is no error here, since there's no <- operator, the construct is unabiguous, it just looks weird.
Feb 10 2009
Kagamin Wrote:auto r = find(range, {a -> a.Weight <- 100});
Take a look at how the Fortress language manages spaces inside expressions. It can find a syntax error there, because the spacing is misleading.
There is no error here, since there's no <- operator, the construct is unabiguous, it just looks weird.
well, every construct can look weird in some environment.
Feb 10 2009
Kagamin:There is no error here, since there's no <- operator, the construct is unabiguous, it just looks weird.
In Fortress the syntax of this expression is OK: x + 2 * 3 x + 2*3 This is a syntax error, because the spaces are misleading: x+2 * 3 Bye, bearophile
Feb 10 2009