From: mark hahn Date: 2001-11-29T06:53:55+09:00 Subject: [ruby-talk:26842] Re: Ref Counting (was KDE or GNOME curiosity question...) I have run into the db problem myself. I coded java apps using a jdbc driver with a 10-connection license. Connections being left open was a big problem. In this case, the java try/finally block worked great and I had no complaint whatsoever. I did this in at least 5 different apps. This worked even when other code was using the connection but I made sure the objects running the other code also dissapeared in the finally clause. I suspect than any properly architected oo code can have this property. ----- Original Message ----- From: "Paul Brannan" To: "ruby-talk ML" Sent: Wednesday, November 28, 2001 1:32 PM Subject: [ruby-talk:26837] Re: Ref Counting (was KDE or GNOME curiosity question...) > On Thu, 29 Nov 2001, mark hahn wrote: > > > I'm thinking now that using scope is the only good way to get quick > > finalization, with the fopen/block trick being the best example. > > The problem with scoping is that it doesn't work if you need to share the > object among many different other objects. > > I've never personally run into this problem, but I know that it can come > up. Just recently, in [ruby-talk:25477], there was talk of wanting to > close a database connection automatically. To summarize, the author > wanted to use a finalizer, but he was (fortunately) able to use scoping > instead. Matz said he was in favor of explicit disconnection from the > database. However, imo, explicit disconnection could be error-prone, but > it's probably the only reliable way to do this in Ruby for the cases where > a block will not suffice. > > Paul >