Why exactly is everything an expression in @rustlang ? Please show me a case where I'd use `continue`, or `break` in the context of an *expression*.
-
-
Replying to @ArvidGerstmann
The guessing game in the book uses continue as an expression. https://doc.rust-lang.org/stable/book/ch02-00-guessing-game-tutorial.html#handling-invalid-input …
1 reply 0 retweets 3 likes -
Replying to @rustlang @ArvidGerstmann
In general though, languages tend to choose to make things either all expressions, or all statements. We’re very close to, but not quite, everything as an expression. I’d flip the question around, what makes having more statements a benefit?
1 reply 0 retweets 1 like -
Replying to @rustlang @ArvidGerstmann
Languages do this for consistency reasons; the more consistent you can get things, the better. Forcing these things to be statements would only make them usable in less places, or more awkward to use
1 reply 0 retweets 0 likes -
Replying to @rustlang
Most languages I've worked on so far have a healthy mix of both. Essentially, it's an expression if it makes sense to use in a context of an expression. Generally, there is always the escape hatch with compound expressions `{ ... }`.
1 reply 0 retweets 0 likes -
Replying to @ArvidGerstmann @rustlang
How does `if return 5 {};` ever come up in real code? Or `5 + return;` (grammatically legal in rust, since return is an expression)?
1 reply 0 retweets 1 like -
Replying to @ArvidGerstmann
Sure, some usages don’t make a lot of sense. That doesn’t mean that all of them make no sense.
2 replies 0 retweets 0 likes
Anyway, this is probably better served on http://users.rust-Lang.org ; this is a hard convo to have on Twitter .
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.