Bug 1938 – member of scope-class-type behavior undefined

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-03-25T01:08:31Z
Last change time
2019-06-14T01:39:33Z
Keywords
C++, spec
Assigned to
No Owner
Creator
david

Comments

Comment #0 by davidl — 2008-03-25T01:08:31Z
scope class A { this() { printf("hello!"); } } class B { private: A t; // possible way of embedding A t as C++ class-type // members. in D we only gets A *t corresponding C++ code. // this gives great optimization of not heap allocating // twice. sizeof(B) will count in embeded A members. // in real world each B object gets an A instance embeded, // therefore calling of allocating space for A is saved, // yet you still need to invoke C-tors of A. There init-list // becomes useful. // D2.0 traits stuff should still behave in the old way. public: this() { printf ("B !!"); } } void main() { B b; b = new B; } testd.d(11): variable testd.B.t globals, statics, fields, ref and out parameters cannot be auto testd.d(11): variable testd.B.t reference to scope class must be scope
Comment #1 by petar.p.kirov — 2017-08-27T09:13:50Z
Re-targeting to D2 as I believe this is a good enhancement request. Also may benefit C++ interoperability.
Comment #2 by pro.mathias.lang — 2019-06-14T01:39:33Z
Scope classes are deprecated, closing