[Issue 4621] Destructors are inherently un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 11 12:33:14 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4621



--- Comment #4 from Michel Fortin <michel.fortin at michelf.com> 2010-08-11 15:33:11 EDT ---
The problem with structs is that many structs will need a destructor because
they encapsulate a resource not managed by the GC. That destructor can be made
GC-heap safe, and thus this struct can be put in a class. For instance, a File
struct wrapping a file handle could easily be made GC-heap safe if it's
destructor just calls fclose(handle), and thus could be put in a class. Are you
willing to make this File struct unusable in SafeD? Or std.container.Array,
which is totally safe to use on the heap too?

So I think there is a need to distinguish GC-safe structs from those that
aren't. Forbidding all structs with a destructor to be put on the heap in SafeD
is going to prevent too many useful things. Obviously, the struct itself would
need a @trusted destructor.

-- 
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