From: Dave Thomas Date: 2001-11-24T12:26:20+09:00 Subject: [ruby-talk:26288] Re: Ruby GC Determinism [Was: KDE or GNOME curiosity question...] Phlip writes: > So consider this pseudo Ruby: > > aConcept = Concept.new > begin > doStuffThatMightRaise (aConcept) > ensure > aConcept.changeMouse(Arrow) > end > > In this code, we are forced to know that Concept has side-effects, and that > these must be rolled-back before the current function exits. This means we > must couple the calling code to what the called code needs, and its > interface is not as narrow as it could be. We called no method on aConcept > that change the mouse pointer away from an arrow, but we must still change > it back reliably. So refactor to decouple it Concept.create do |aConcept| GUI.indicate_working do aconcept.doStuff end end of somesuch. Sometimes tangled resource allocation and the like is a symtom of a different problem. I'm not saying my code above is the answer, but in best RJ style, I'll bet you could find one. Regards Dave