| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
February 10, 2009 Re: Lambda syntax, etc | ||||
|---|---|---|---|---|
| ||||
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});
:)
| ||||
February 10, 2009 Re: Lambda syntax, etc | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kagamin | 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
| |||
February 10, 2009 Re: Lambda syntax, etc | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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.
| |||
February 10, 2009 Re: Lambda syntax, etc | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kagamin | 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.
| |||
February 10, 2009 Re: Lambda syntax, etc | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kagamin | 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
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply