Ruby "finalize", "__del__" 
Author Message
 Ruby "finalize", "__del__"

Hi,
is there a "finalize" method for Ruby classes which is called just before
being sweeped out by GC. (counterpart to "initialize", i.e. a destructor).
I don't want to use the ObjectSpace.define_finalizer() for all instances of
my class (i.e. by overloading the new-method).
Any hints?
Thanks
Clemens


Mon, 26 May 2003 03:00:00 GMT  
 Ruby "finalize", "__del__"
Hi,

In message "[ruby-talk:6889] Ruby "finalize", "__del__""

|is there a "finalize" method for Ruby classes which is called just before
|being sweeped out by GC. (counterpart to "initialize", i.e. a destructor).
|I don't want to use the ObjectSpace.define_finalizer() for all instances of
|my class (i.e. by overloading the new-method).

No.  It is not provided intentionally.

"finalizer" methods are very troublesome for GC.  Since it often
"resurrects" the dying objects.  How about calling define_finalizer in
initialize method?  See tempfile.rb for example.

                                                        matz.



Wed, 28 May 2003 22:47:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

2. BEGIN{want[]={"s1o", "s2o", "s2q", "s3q"}

3. Parsing ""D""?

4. "Fifth", "Forth", zai nar?

5. beginners "let"/"random" question

6. ANNOUNCE: new "plus"- and "dash"-patches available for Tcl7.5a2/Tk4.1a2

7. Looking for "stdin", "stdout"

8. "exception in foo.__del__() ignored" strangeness

9. "exception in FancyURLopener.__del__ ignored"

10. Del's "except"ional PEP Rejection

11. Hi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "Two") text1.sub!("@BLAH", "Two") print text0,"\n" print text1,"\n" produces thiHi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "T

12. Match "ab" in "abc", but not in "abd"

 

 
Powered by phpBB® Forum Software