www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1297] New: Static modules, aka enforcing static import.

reply d-bugmail puremagic.com writes:

           Summary: Static modules, aka enforcing static import.
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: ibisbasenji gmail.com

I find myself using the very nice static-renaming-import scheme to provide
namespacing capability.  For example, rather than have a module full of
database functions with, for example, a 'db_' prefix to avoid collisions, its
useful to just use 'static import Db = foo.bar.Db;' and call all functions via

Since some modules are tailored toward use in this way, I feel it would be nice
to have a way to specifically enforce our module being static-imported.  The
proposal is simple enough: allow the 'static' attribute on 'module'
declerations, with the meaning that any corresponding 'import' must also be
'static'.  Example:

-----[ foo/bar/Db.d ]-----
static module foo.bar.Db;

void func () {}

-----[ fred.d ]-----
import foo.bar.Db; // <- Error: import for module 'foo.bar.Db' must be static

-----[ greg.d ]-----
static import foo.bar.Db; // <- Ok

Naturally, static-modules should still play nice with renaming imports and
selective imports.

Jun 28 2007
parent d-bugmail puremagic.com writes:

--- Comment #1 from Leandro Lucarella <llucax gmail.com> 2009-11-13 15:32:20
PST ---
I think static import should be the default, and there should be an explicit
way to import everything, not the other way around.

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