[#600] A `File' is not a `IO'????? — clemens.hintze@...

17 messages 1999/08/10
[#602] Re: A `File' is not a `IO'????? — matz@... (Yukihiro Matsumoto) 1999/08/10

Hi,

[#679] Documentation about RD? — Clemens Hintze <c.hintze@...>

Hi,

78 messages 1999/08/17
[#680] Summary of discussion about RD (Re: Documentation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/18

=begin

[#683] Re: Summary of discussion about RD (Re: Documenta tion about RD?) — clemens.hintze@... 1999/08/18

On 18 Aug, Toshiro Kuwabara wrote:

[#686] Re: Summary of discussion about RD (Re: Documenta tion about RD?) — gotoken@... (GOTO Kentaro) 1999/08/18

Hi,

[#687] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — clemens.hintze@... 1999/08/18

On 18 Aug, GOTO Kentaro wrote:

[#693] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/18

Hi,

[#695] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — Clemens Hintze <c.hintze@...> 1999/08/18

On 19 Aug, Toshiro Kuwabara wrote:

[#697] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/19

Hi,

[#703] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — Clemens Hintze <c.hintze@...> 1999/08/19

On 19 Aug, Toshiro Kuwabara wrote:

[#706] Re: Summary of discussion about RD (Re: Docum enta tion about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/19

Hi,

[#681] Re: Summary of discussion about RD (Re: Documentation about RD?) — gotoken@... (GOTO Kentaro) 1999/08/18

Hi,

[#682] Re: Summary of discussion about RD (Re: Documentation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/18

Hi,

[#684] Re: Summary of discussion about RD (Re: Documentation about RD?) — TAKAHASHI Masayoshi <maki@...> 1999/08/18

Hi Tosh and all,

[#685] Re: Summary of discussion about RD (Re: Documentation about RD?) — gotoken@... (GOTO Kentaro) 1999/08/18

Hi,

[#689] Re: Summary of discussion about RD (Re: Documentation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/18

Hi,

[#694] Re: Summary of discussion about RD (Re: Documentation about RD?) — matz@... (Yukihiro Matsumoto) 1999/08/18

Hi,

[#700] Re: Summary of discussion about RD (Re: Documentation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/19

Hi,

[#702] Re: Summary of discussion about RD (Re: Documentation about RD?) — matz@... (Yukihiro Matsumoto) 1999/08/19

Hi,

[#704] Re: Summary of discussion about RD (Re: Docum entation about RD?) — Clemens Hintze <c.hintze@...> 1999/08/19

On 19 Aug, Yukihiro Matsumoto wrote:

[#719] Re: Summary of discussion about RD (Re: Docum entation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/20

Hi,

[#720] Re: Summary of discussion about RD (Re: Docum entation about RD?) — clemens.hintze@... 1999/08/20

On 20 Aug, Toshiro Kuwabara wrote:

[#721] Re: Summary of discussion about RD (Re: Docum entation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/20

Hi,

[#722] Re: Summary of discussion about RD (Re: Docum entation about RD?) — clemens.hintze@... 1999/08/20

On 21 Aug, Toshiro Kuwabara wrote:

[#723] Re: Summary of discussion about RD (Re: Docum entation about RD?) — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 1999/08/20

Hi,

[#737] RD with multi charset — Minero Aoki <aamine@...>

Hi, I'm Minero Aoki. This is my first mail in this mailling list.

26 messages 1999/08/22

[ruby-talk:00626] Next misbehavior (sorry :-)

From: clemens.hintze@...
Date: 1999-08-11 10:35:04 UTC
List: ruby-talk #626
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 :-))

In This Thread

Prev Next