Yukihiro Matsumoto wrote:

> Ruby and many other languages with GC (Java is in the same boat) allow
> resource finalization when the object is "destroyed".

I haven't gotten this far in Ruby, but I understand that in Python 
'__del__' might never call, this means you can't put anything useful in it 
(such as code to change the mouse pointer from a temporary icon back into 
an arrow).

That's what RAII means; it means your local variables' lifespans should 
track your system state.

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.

This is the style that Java coders take for granted & expect.

I'm not knocking 'ensure' (it's a pain to add in C++, for example). But in 
Ruby if a destructor rolled state back, would it deterministically call 
right when aConcept clears its last scope barrier? or is the above code 
required?

-- 
  Phlip                          phlip_cpp / yahoo.com
           http://sourceforge.net/projects/flea
  --  Founding member of NuGWa -
        Nudists for Global Warming  --