Thread overview
[Issue 3603] New: Allow selective import syntax to import several modules from a package
Dec 08, 2009
Leandro Lucarella
Oct 15, 2012
Manu
Jan 23, 2013
Nick Treleaven
December 08, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3603

           Summary: Allow selective import syntax to import several
                    modules from a package
           Product: D
           Version: future
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: llucax@gmail.com


--- Comment #0 from Leandro Lucarella <llucax@gmail.com> 2009-12-08 13:49:19 PST ---
Importing a lot of stuff from a deeply nested modules is very annoying because it needs a lot of repeating, for example:

import really.very.deeply.nested.package.module1;
import really.very.deeply.nested.package.module2;
import really.very.deeply.nested.package.module3;

Allowing selective import syntax to do this in a more concise way would be a great improvement over this, the above example could be rewritten as:

import really.very.deeply.nested.package: module1, module2, module3;

Maybe this should be semantically equivalent to this instead of the first example:

import module1 = really.very.deeply.nested.package;
import module2 = really.very.deeply.nested.package;
import module3 = really.very.deeply.nested.package;

It can be a little more consistent with selective imports. But we still have to same problem if we don't want to type module1.symbol and want to type just symbol instead.

Maybe a new syntax can be introduced to allow that, like:
import really.very.deeply.nested.package { module1, module2, module3 };

Or something similar.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3603


Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |turkeyman@gmail.com


--- Comment #1 from Manu <turkeyman@gmail.com> 2012-10-15 06:38:05 PDT ---
Massive +1 from me! (only 3 years later)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3603


Nick Treleaven <ntrel-public@yahoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ntrel-public@yahoo.co.uk


--- Comment #2 from Nick Treleaven <ntrel-public@yahoo.co.uk> 2013-01-23 08:55:04 PST ---
> import really.very.deeply.nested.package: module1, module2, module3;

I think this is the way to go, and is very commonly useful.

> import really.very.deeply.nested.package { module1, module2, module3 };

I don't think it's worth allowing both selective modules and selective symbols in the same statement. Importing selective symbols from a module can just use a separate statement, and it's less common than full module imports anyway.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3603


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #3 from bearophile_hugs@eml.cc 2013-01-24 18:17:12 PST ---
I'd like to write:

import std: stdio, algorithm, range, array;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------