[ruby-talk:00177] Re: destructor ?

From: matz@... (Yukihiro Matsumoto)
Date: 1999-01-07 04:22:24 UTC
List: ruby-talk #177
Hi.

In message "[ruby-talk:00176] destructor ?"
    on 99/01/06, "Bryce" <crowdog@siscom.net> writes:

|I now know that "def initialize" is the constructor of
|a class.  Could someone please tell me what the
|destructor is ?  And any other helpful class info please?

C wrapper objects, whose type is T_DATA, have the finalizing function,
as 2nd argument to Data_Wrap_Struct() macro.

The function will be called when the object is reclaimed, with wrapped
pointer as only argument.

There's no easy way to define finalizer in Ruby level.  But it's not
impossible.  See lib/tempfile.rb.  Or ask Clemens, who had struggled
with it. :-)

I believe GC and C level finalizers can handle most of the probems.

                                                matz.

In This Thread

Prev Next