From: Paul Brannan Date: 2002-07-02T03:35:29+09:00 Subject: Re: Ruby implementation Q's On Tue, Jul 02, 2002 at 02:54:00AM +0900, Yukihiro Matsumoto wrote: > Ruby's finalization is kept very primitive intentionally. It's not > for everybody. Some classes implement optional (or explicit) destroy > mechanism, for example: > > a = open("/dev/null", "w") > a.print "foo" > a.close > a.print "bar" # => exception! "closed stream" Also note that this isn't exception-safe, since a doesn't get closed if the first a.print raises an exception. The idiomatic way to do this in Ruby is using blocks. Explicit destruction is almost never a good idea, since it's far too easy to forget or to create a code path that happens to skip destruction. Paul