[Issue 15171] New: private/protected/package default construction
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Oct 7 03:13:31 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15171
Issue ID: 15171
Summary: private/protected/package default construction
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
As the unit of encapsulation is the module, it sometimes makes sense to manage
construction of a certain type on a by-module basis instead of a by-type basis.
Therefore, the following code should compile:
struct S{
private this();
private init;
// (probably we also want @disable init, instead of
// needing to hack around lack of it by hiding it
// with a new declaration.)
}
Within the module, S should be default-constructible and S.init should be
accessible, but not outside the module.
This gives the author of the type full control over how S is constructed, but
it does not unduly constrain the author.
package and protected default construction are analogous. Probably, explicit
'public' should be allowed as well.
--
More information about the Digitalmars-d-bugs
mailing list