DIP16: Transparently substitute module with package

Brad Anderson eco at gnuk.net
Fri Mar 30 11:15:44 PDT 2012


On Fri, Mar 30, 2012 at 12:06 PM, Andrej Mitrovic <
andrej.mitrovich at gmail.com> wrote:

> On 3/30/12, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> > Destroy!
>
> "That means a program that imports std.algorithm may use "std.sort"
> for the symbol "std.algorithm.sort"."
>
> That's quite interesting. Would that also mean that you could do:
> import std.algorithm;  // has indexOf
> import std.string;  // has indexOf
> void main() {
>    string.indexOf("foo", "foo"); -> std.string.indexOf
> }
>
>
I was actually kind of surprised when I found out this doesn't work.  It
seems so natural to resolve ambiguity using as little context as necessary.


> That would ease usage of Phobos a little bit. OTOH 'string' already is
> a keyword and things might get hairy..
>
> Still this is one of the few proposals I like. My only caveat is the
> comment: "except the file is not allowed to use the "module"
> declaration.". Wouldn't it be better if we explicitly declared a
> module as a package instead? In foo\bar\package.d:
> package foo.bar;
>
> Since the "module" declaration must be on the first line (or second
> line after shebang), you could special-case DMD to allow the package
> keyword to be used here. I know D likes to abuse a keyword for
> multiple things (hello Mr. Static!), but I think we could live with
> it.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120330/26a1cca1/attachment-0001.html>


More information about the Digitalmars-d mailing list