-
Notifications
You must be signed in to change notification settings - Fork 13.4k
block syntax redundant #1854
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
Comments
@nikomatsakis and I were discussing this the other day, thinking that perhaps the function kind inferrence on lambda blocks is too clever. To make the function syntax more usable we can do as you suggest and make the argument types optional. Additionally we were thinking that we could omit the parens for functions without arguments, so spawn would look like
|
We could go as far as you suggest and remove block syntax. |
Yes, I'm now a fan of allowing I am not sure how I feel about removing
doesn't look right to me. But maybe it just takes getting used to (Even in that example, I am assuming we allow |
Agreed. |
How about go the other way and make the normal function definition just be a let statenent that binds a lambda of some sort? I really like the idea of unifying syntaxes though, but it's worth considering changing the declaration to be more like the expression, instead of going the other way. Also, it would be cool if there wasn't two ways to declare a function (either by using special-case function declaration syntax, or just creating a lambda, of some sort, and assining it to a variable). Maybe get rid of special function declarations, and do something like:
These all sort of look enough like function definitions, but are really just declaring a variable like any other. EDIT: oh, this is kind of a strawman proposal. I haven't considered how this syntax would be parsed. I can imagine it might be ambiguous or something. |
As a Lisper, I would love to have |
I realize that I'm in a minority here, but (perhaps due to the scarcity of documentation and my own lack of expertise) I often have trouble passing functions around in Rust. In addition (and here I'm guessing I'm even more in the minority) I often don't even care about the types of the arguments and return values of my functions; all I want is for my functions to "just work". In both these cases, the Perhaps this is a use case that you don't really care if Rust supports--loose "script-like" programming where the programmer isn't really paying attention to what he's doing, and if that's the case then I understand. But far from making it harder to learn the language, Rust's block syntax (occasionally) frees me from stalling out on laboriously specifying function signatures, allowing me to continue learning other aspects of the language. |
From rust-dev mailing list: I am not in favor of removing named fn items for several reasons.
No doubt these issues can be addressed, but just making "fn foo(x,y)" sugar for "let foo = {|x, y| ...}" will not be very usable by itself (imo). |
I am going to close this issue and open a new one more narrowly tailored to the proposal that @brson described. I don't think we will remove block syntax nor named fn items---and, if we were going to do it, I'd like to see a more detailed proposal addressing the concerns I described above. If anyone disagrees, please feel free to re-open. |
Also adds proper checking for cont/break being inside a loop. Closes rust-lang#1854 Issue rust-lang#1619
Rust's block syntax is redundant. Why not use the same syntax as function definitions, just omit the name like JavaScript and Lisp do?
This would simplify the compiler and making learning Rust that much easier.
The text was updated successfully, but these errors were encountered: