Thread overview
Re: Lambda syntax, etc
Feb 10, 2009
Kagamin
Feb 10, 2009
bearophile
Feb 10, 2009
Kagamin
Feb 10, 2009
Kagamin
Feb 10, 2009
bearophile
February 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});

:)
February 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
February 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.
February 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.
February 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