On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote:
You know about static imports, right?
Yes, as well as about renamed and selective ones ;)
Problem with static imports is that they are all-or-nothing. And
in our projects it is common to have module names with 5 nested
packages or even more. Typing all of it is impractical - simple
prefix gives enough protection from random clashes.
D module system is completely broken in that regard.
What's the alternative?
When doing my old "Rust vs D" comparison I have been mentioning
their import semantics as a big win. When you do import like this:
use phrases::english::greetings;
You must always also qualify symbol name with module name like
this:
println!("Hello in English: {}", greetings::hello());
And this won't compile:
println!("Hello in English: {}", hello());
It has similar benefits as the idiom proposed in this topic -
greatly reduced risk of accidental clashes.