From: Paul Brannan Date: 2002-07-04T01:19:53+09:00 Subject: Re: Ruby implementation Q's On Thu, Jul 04, 2002 at 12:12:14AM +0900, Peter Hickman wrote: > Good question. > > If the program requires that dosomethingwiththedata() actually work then > i think that the program would have to terminate and thereby free the > resources. > > If however it was a more minor error that dosomethingwiththedata() could > detect within itself before raising the exception then maybe it could > deallocate the resources before raising the exception. > > Again this is just guesswork, someone with more knowledge of the C > interface should come in here. There's a better idiom: http://www.rubygarden.org/ruby?RubyStyleGuide/UseBlocksForResourceManagement http://www.rubygarden.org/ruby?RubyIdioms http://www.rubygarden.org/ruby?ResourceAcquisitionIsInitialization This works well from inside Ruby and from C (using rb_yield()), but it does not solve every problem: http://www.ruby-talk.org/16958 http://www.ruby-talk.org/35478 And note that explicit destruction has already been discussed before: http://www.ruby-talk.org/34631 Paul