[Issue 10404] New: Class!T should be the class version of type T
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 18 07:39:06 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10404
Summary: Class!T should be the class version of type T
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrei at erdani.com
--- Comment #0 from Andrei Alexandrescu <andrei at erdani.com> 2013-06-18 07:39:05 PDT ---
Given a struct S with state and methods, Class!S should be a type that:
* is a class type
* contains exactly one member, having type S
* has constructors that forward to S's constructors
* has the same methods as S, with implementations that forward to the member's
methods
This offers an immediate means to convert a struct into a class that has the
same functionality but typical class semantics (heap allocation, reference
semantics, overridable methods etc).
Further ideas:
* define a clone() method that duplicates the state by copying the S member
* allow S to be a primitive type
* offer flags such as "all methods should be overridable" or "all methods
should be final", i.e. Class!(S, ClassOptions.allOverridable) vs. Class!(S,
ClassOptions.allFinal).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list