Paul Brannan <pbrannan / atdesk.com> writes:

> > Use the block paradigm instead. E.g.
> >
> > DBI.connect do | dbh |
> >   # do something with dbh
> > end
>
> This works fine for short-lived objects, but how can I use blocks for
> objects that get passed around?  I think that would be a case where I
> would have to implement my own reference counting in Ruby.

Hey, ruby does have a memory management system, it just doesn't ensure
finalisation as soon as possible!

IMO block paradigm can take care of case when you want to ensure to destructor
to be called when out of scope. When the object outlive current scope, waiting
for GC is no such big deal.


--
Pixel