From: Michal Rokos Date: 2002-04-23T23:55:28+09:00 Subject: Re: building extensions-- new vs initialize In article <200204230851.g3N8pVu11089@sharui.nakada.kanuma.tochigi.jp>, nobu.nokada@softhome.net wrote: > In general, redefinition of "new" will be deprecated in 1.8. > Instead, you have to do are: Is there any documentation about new features and needs? In NEWS there is just a note that "any instance of class can be allocated by class.allocate, (except a few classes)." Michal > (1) define "allocate" class method, > (2) define "initialize" instance method, > (3) call rb_call_super() in "initialize", and > (4) call rb_enable_super() for "initialize" in Init_xxx(). > > Although 3 and 4 are not necessary, I recommend them. I hope > rough/ext/stringio.c to be an example. As a sidenote: I noticed 1 miss while reading your source. This illustrates the miss: rb(main):001:0> require 'stringio' true irb(main):002:0> class StringIO irb(main):003:1> def initialize irb(main):004:2> end irb(main):005:1> end nil irb(main):006:0> s = StringIO.new # irb(main):007:0> s = nil nil irb(main):008:0> GC.start (irb):8: [BUG] Segmentation fault ruby 1.7.2 (2002-04-19) [i586-linux] Aborted (I hope this form is better for you than to write directly where is point is.) -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Michal Rokos Czech Technical University, Prague E-mail:m.rokos@sh.cvut.cz ICQ:36118339 Jabber:majkl@jabber.sh.cvut.cz -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-