digitalmars.D.bugs - [Issue 1297] New: Static modules, aka enforcing static import.
- d-bugmail puremagic.com (33/33) Jun 28 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1297
- d-bugmail puremagic.com (7/7) Nov 13 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1297
- d-bugmail puremagic.com (15/15) Feb 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=1297
http://d.puremagic.com/issues/show_bug.cgi?id=1297 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 'Db.func()'. 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
http://d.puremagic.com/issues/show_bug.cgi?id=1297 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
http://d.puremagic.com/issues/show_bug.cgi?id=1297 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 17:07:34 PST --- Since D is supposed to prevent symbol hijacking I don't see much benefit for this. If the user has conflicts he will use one of several techniques such as using static imports, using aliases, using renamed imports and/or selective imports. I don't see why you would force a module to be imported one way or another. It seems like a sure way to make importing modules annoying for the user. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2013