Firstly, you must type {}
in rust, and if you are using println!
macros, typing {}
inside the format string is unavoidable.
Secondly, I tried search German Keyboard Layout, found that, one could type {}
easily if it has no less than 3 fingers and one hand.
At least I could type 7 and 0 with 2 fingers while right Alt key pressed by my thumb.
What's more, if Germany thought press AltGr is harder, they should wrote code like:
let a=vec!(0;5); // equivlent to `let a=vec![0;5];`, which compiles at least now.
But until now, I have not seen such code.
sorry for the rule I've forgotten, I'd wrote it later...
If you wrote a macro using a constructor's syntax, you should create a struct. But if you just heppened to wrote a struct with the same name, the expand rule works fine.In your case,
struct try { x: i32 }; // definately a struct let x = 4; // that's OK. let y: try = try{x}; // try{x} is not a legal constructor (at least for now), thus it could be fall back to try macro, which might provide a try struct.
Currently,
StructName{field_value}
is not legal, but if we allow using macros, we could makeStructName{field_value}
expand toStructName{field_name:field_value}
. And if you wantStructName{things}
to be a macro, it is indeed a macro.
Further, the novel macro syntax may help for writting new constructors:
let a=Vec{ptr:...,len:0,cap:0}; // constructor
let a=Vec{0;5}; // macro, since it is not a legal constructor grammar.
With help of the novel macro syntax, we could wrote such macros:
let map=HashMap{
("key","val"),
"delim"=>"could be either comma or semicolon";
("or","just")("omit","the delimiter")
} // currently there is no hashmap macros like `vec!`, but we could provide it in the future.
If we have procedure macros, we might even wrote
let map=HashMap{iter:my_iterator}; // or `let map=HashMap{iterator};`
In this case, we may save a lot of works for naming constructors.
This is why I want to unify the namespace.
After namespace is unified, there is no problem about "knowing which namespace to lookup"