D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10022 - Importing packages
Summary: Importing packages
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: yebblies
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2013-05-03 14:17 UTC by yebblies
Modified: 2013-07-13 23:01 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description yebblies 2013-05-03 14:17:08 UTC
When an import resolves to a package, instead import a module inside the package called 'package'.  Usual rules are then followed as if it was imported explicitly.

When both a module and a package exist, the compiler gives an ambiguity error.
Comment 2 Andrej Mitrovic 2013-05-03 15:24:52 UTC
Same as Issue 3603?
Comment 3 yebblies 2013-05-03 15:35:53 UTC
(In reply to comment #2)
> Same as Issue 3603?

No.
Comment 4 Jonathan M Davis 2013-05-04 17:55:29 UTC
> Same as Issue 3603?

No, it's a variant of DIP 15. It'll make it so that you could do something like replace std/datetime.d with

std/datetime/common.d
std/datetime/interval.d
std/datetime/package.d
std/datetime/timepoint.d
std/datetime/timezone.d

and std/datetime/pakckage.d could then look something like

--------------
/++ Package documentation here +/
module std.datetime.package;

public import std.datetime.common;
public import std.datetime.interval;
public import std.datetime.timepoint;
public import std.datetime.timezone;
--------------

So, std.datetime could then be broken up and no code would break. It would also likely replace the all.d idiom that some people have been using to make it so that you can import an entire package at once, since it's basically all.d with compiler support. Even better, it also then gives us a way to document packages.

We discussed it with Andrei and Walter at dconf after Adam Wilson was complaining about the lack of this sort of ability in his talk, and we eventually got Andrei and Walter to agree to it.
Comment 5 Andrej Mitrovic 2013-05-05 03:08:41 UTC
(In reply to comment #4)
> --------------
> /++ Package documentation here +/
> module std.datetime.package;
> 
> public import std.datetime.common;
> public import std.datetime.interval;
> public import std.datetime.timepoint;
> public import std.datetime.timezone;
> --------------

I see. This is a good idea, but public import modules do have their bugs, e.g. the recently fixed Issue 9919. I've ran into a few others over the years.
Comment 6 yebblies 2013-05-05 09:13:24 UTC
(In reply to comment #5)
> 
> I see. This is a good idea, but public import modules do have their bugs, e.g.
> the recently fixed Issue 9919. I've ran into a few others over the years.

Bugs are just bugs, we will just have to fix them as they appear.
Comment 7 Jonathan M Davis 2013-05-05 22:17:11 UTC
http://wiki.dlang.org/DIP37
Comment 9 yebblies 2013-07-13 23:01:31 UTC
This has been implemented.