Hi,

I currently try to derive my class `StringIO' from  `String', because
to simplyfy thinks a little bit. Now I am struggled over the next
trap...

Please consider following script:

	class MyString<String
	    def initialize(*args)
	        print "Enter `initialize' with args=`#{args}'\n"
	        super *args
	        print "After parent initialization\n"
	    end

	    def show
	        print to_s, "\n"
	    end
	end

	mys1 = MyString.new "hello world"
	mys1.show

=> hello world

As you can see, the initialize routine will not invoked.

I was struggle over the same trap as I wrote an own example how to build
an own C-coded class for Ruby. I have only provided a new method, and do
all the initialization there. After derivation I have found, that the
initialization function was not invoked.

So quick have a look on `string.c' function `rb_str_s_new'... indeed,
there lacks a call to `rb_obj_call_init'!

Could we get it fixed? And for other classes also? Following script
(based on Gotoken's one):


    module Init
        def initialize(*args)
            print "Enter `initialize'"
        end
    end
    

    objs = [ Object.new, 0, 0.0, 10**10, 1..10, Class.new, Module.new, 
             "", {}, [], //, STDOUT, open("/dev/null"),
             Struct.new("F").new, Time.now]

    args = [nil, [1], [1,2], ["a"], ["a","w+"]]
    
    
    objs.each do |obj|
        klass = obj.type
        newklass = Class.new klass
        newklass.class_eval %(include Init)
        print "\n#{newklass.superclass} ... "
        curargs = args.clone
        begin
            arg = curargs.shift
            newobj = newklass.new *arg
        rescue
            unless curargs.empty?
                retry
            else
                print "#{newklass.superclass} has no `new' method"
            end
        end 
    end
    print "\n"

shows:

Object ... Enter `initialize'
Fixnum ... Fixnum has no `new' method
Float ... Float has no `new' method
Bignum ... Bignum has no `new' method
Range ...
Class ...
Module ...
String ...
Hash ...
Array ...
Regexp ...
IO ...
File ...
Struct::F ... Enter `initialize'
Time ...  

Only `Object' and `Struct' instances seems to call `initialize'.
Furthermore some classes have no `new' method. would it make sense to
add one (for alibi purposes)?

\cle    

PS: I go to have a look at the dark sun today here in Germany :-))