From: Phlip Date: 2001-11-25T06:18:41+09:00 Subject: [ruby-talk:26366] Re: Ruby GC Determinism [Was: KDE or GNOME curiosity question...] Bill Kelly wrote: > That is, it's an extra distinction about objects, or object > allocation, that languages like Ruby or Java don't have. . . > So C++'ers utilize this guaranteed "out of scope destruction" > of locally allocated objects to implement things like smart > pointers (such as std::auto_ptr<>) which can perform an automatic > delete on the type of (heap allocated) object to which they > point, as the smart pointer itself (a locally allocated stack > frame object) goes out of scope. In the light of exception safety, the above must be said the other way around; given the requirement that exceptions roll state back cleanly, the best OO models will take care that their 'ensure' blocks are automatic, and not coupled to the calling code that experienced the exception. So C++ers use destructors, and programmers using languages with garbage collection and blocks use the "Execute Around Method" pattern (from /Smalltalk Best Practice Patterns/, page 37, by Bent Keck). > where is in GC'd languages one need only ensure deterministic > cleanup of objects holding non-memory resources. If an exception blew away your current context, would your system state roll back completely and cleanly to the point it was at before the 'begin'? -- Phlip http://www.greencheese.org/HatTrick