On 3/30/12 10:46 PM, Andrei Alexandrescu wrote:
Starting a new thread from one in announce:
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP16
Please comment, after which Walter will approve. Walter's approval means
that he would approve a pull request implementing DIP16 (subject to
regular correctness checks).
Great. Large modules are my main complaint about D. :-)
If I correctly understand the second part (because I couldn't understand
the text in the proposal until I read some comments here), then it makes
sense. Is it like this?
sort(...) -> search sort in every module out there
std.sort(...) -> search sort in every module that's in the std package
If both std.algorithm.sort and std.path.sort exist, or something like
that, then you would anyway get a clash so you'd have to fully qualify it.
But if std.algorithm.sort and foo.bar.sort and you'd import both:
import std.algorithm.package;
import foo.bar.package;
and you'd wanted to use both, then it could be convenient:
std.sort(...)
foo.sort(...)
Though I wonder if this indeed happens a lot. That's why I would wait
until there's a real need for it. The main complaint people have is not
having a way to import all files in a directory, which is the first
point, but I never heard a complaint about the second point.
Also, I think it would make sense to change the first part to this:
* If the compiler sees a request for importing "foo.bar" and "foo/bar"
is a directory, then automatically look for the file
"foo/bar/package.d". *If it doesn't exist, automatically expand the
import to import all files under that directory.* If both "foo/bar.d"
and "foo/bar/" exists, compilation halts with an error.
That way you have convenience and safety. Most of the time people just
put in package.d a list of all the files in that directory. Maybe
sometimes (not sure) people restrict that list to some modules. And in
those cases you can just restrict the list in package.d
Please, it's the year 2012. Compilers need to be smarter. Save people
some typing time. You save them typing all the imports. But then you
make them typing them in that pacakge.d file. Hmm...