digitalmars.D - hasElaborateDestructor
- claptrap (5/5) Apr 27 What the heck does elaborate mean in this context? I mean a type
- Luna (9/14) Apr 27 Elaborate refers to destructors which are not automatically
- Paul Backus (8/13) Apr 27 `hasElaborateDestruction!T` is `true` if and only if (a) `T` has
- Adam Wilson (5/10) Apr 28 Renamed to `hasComplexDestruction` in Phobos 3. You can even use
What the heck does elaborate mean in this context? I mean a type has a destructor or not right? Why is a struct destructor called "elaborate" and a class destructor not? Or is this just another case of programmers cant think up sensible names for stuff?
Apr 27
On Sunday, 27 April 2025 at 21:43:26 UTC, claptrap wrote:What the heck does elaborate mean in this context? I mean a type has a destructor or not right? Why is a struct destructor called "elaborate" and a class destructor not? Or is this just another case of programmers cant think up sensible names for stuff?Elaborate refers to destructors which are not automatically generated by the D compiler; eg. If you have a type with subtypes that can be destroyed D will automatically set up a destructor that handles the destruction chain for you. But if you define your own destructor; potentially in a template your destructor now becomes elaborate since it has more functionality than just ensuring its children are destroyed if needed. Elaborate destructors only apply to structs however, not classes.
Apr 27
On Sunday, 27 April 2025 at 21:43:26 UTC, claptrap wrote:What the heck does elaborate mean in this context? I mean a type has a destructor or not right? Why is a struct destructor called "elaborate" and a class destructor not? Or is this just another case of programmers cant think up sensible names for stuff?`hasElaborateDestruction!T` is `true` if and only if (a) `T` has a destructor, and (b) a local variable of type `T` will have that destructor called on it at the end of its scope. It returns `false` for classes because classes are reference types, and the destructor on a class *instance* is not called when the *reference* goes out of scope. A more accurate name would be `hasElaborateDestruction`.
Apr 27
On Sunday, 27 April 2025 at 21:43:26 UTC, claptrap wrote:What the heck does elaborate mean in this context? I mean a type has a destructor or not right? Why is a struct destructor called "elaborate" and a class destructor not? Or is this just another case of programmers cant think up sensible names for stuff?Renamed to `hasComplexDestruction` in Phobos 3. You can even use `phobos.sys.traits` in your code right now since it's just a template and the module ships with the standard Phobos distribution.
Apr 28