fn something() {
foobar();
{
bar();
foo();
}
quux();
}
That is much easier to understand, and easier for tools to work with (they can actually automatically indent your code without breaking it), than: def something():
foobar()
bar()
foo()
quux()
edit: And how would you even add a scope right after another block (like if)? That would require you to have a keyword anyway.Whitespace / indentation used for scope delimiting in Python is a bad idea. No, thanks. I'm glad Rust isn't using anything like that.
use std::collections::{HashMap, HashSet};
Are all those ::s and {}s adding to clarity?Why are there no easy to use initializers for maps? It's 2015! I have to do:
let mut map = ::std::collections::HashMap::new();
map.insert("a".to_string(), "b".to_string());
...
or some such nonsense. Oh, right, I have to write a macro and basically learn another language. Also, using the macro system for basic things like println just seems bonkers to me; use macros when you really, really need to do something special, not everywhere.[1]: https://en.wikipedia.org/wiki/C%2B%2B11#Initializer_lists
I.e. I'd prefer to write:
let v: Vec<i32> = {1, 2, 3, 4, 5};
Instead of let v = vec![1, 2, 3, 4, 5];That said, in future, it is likely to be possible for things like `Vec::from_array([1, 2, 3, 4])` and `HashMap::from_array([[1, 2], [3, 4]])` to work.
Exact implementation is another question. That's why asked, whether it's feasible or it's something hard to fit into the language.
I'm not sure I personally feel that the first is particularly better than the latter, but it should have to be by a large margin to justify adding new syntax to the language.
> it should have to be by a large margin to justify adding new syntax to the language.
C++11 put some effort into simplifying some cumbersome syntax constructs. It makes things easier to read and write which pays off.