Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter Syntax for Lambda expressions #10

Closed
Feliix42 opened this issue Nov 2, 2018 · 4 comments
Closed

Alter Syntax for Lambda expressions #10

Feliix42 opened this issue Nov 2, 2018 · 4 comments

Comments

@Feliix42
Copy link
Member

Feliix42 commented Nov 2, 2018

The current semantic is:

let f = fn (d) {calculate(d, x)};

While the Rust-native way would be a construct like this:

let f = |d| calculate(d, x);

For further reference, you may also have a look at the reference.

I think it would be better to alter the syntax and transition to the native closure syntax for more comfort during development.
But as of now, this is not an urgent topic.

@sertel
Copy link

sertel commented Nov 2, 2018

Also eigentlich ist das:

let f = |d| -> () { calculate(d,x); };

Obiges ist nur eine kürzere Art und Weise dies zu schreiben. Das müssen wir aber wirklich nicht unterstützen. (Zumindest nicht zu Beginn.)

@Feliix42
Copy link
Member Author

Feliix42 commented Nov 2, 2018

Not exactly. The type of the above statements in my comment both produce a value, the return value of calculate. The semicolon in your example is too much.

let f = |d| -> i32 { calculate(d, x) };

But this is explained in the reference along with the grammar rules that form such an expression.

@sertel
Copy link

sertel commented Nov 2, 2018

Now that is misleading Rust syntax, at least to me.

@Feliix42
Copy link
Member Author

Feliix42 commented Nov 2, 2018

But it's the same for the original fn syntax, isn't it? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants