Bug 15171 – private/protected/package default construction

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-07T10:13:31Z
Last change time
2024-12-13T18:45:13Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#17727 →

Comments

Comment #0 by timon.gehr — 2015-10-07T10:13:31Z
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.
Comment #1 by robert.schadek — 2024-12-13T18:45:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17727 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB