[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01957] Re: object creation

From: matz@... (Yukihiro Matsumoto)
Date: 2000-03-17 09:20:37 UTC
List: ruby-talk #1957
Hi,

In message "[ruby-talk:01930] Re: object creation"
    on 00/03/16, Dave Thomas <Dave@thomases.com> writes:

|Now I'm probably missing something, but wouldn't calling the
|constructor indirectly also allow the users of the extension override
|the default initialization?

Yes.  For example, Dir#initialize works like reopen.

  d = Dir::new(path)
  d.entries
  d.send(:initialize, newpath) # close dir, then reopen
  d.entries

In addition, overriding `initialize' without calling `super' leaves
the object uninitialized.  

  class SubDir<Dir
    def initialize(path)
    end
  end

  d = SubDir::new(".")
  p d.entries           # in `each': closed directory (IOError)

So making `initialize' redefinable, extension writer should notice
these points.  But I'm not still sure if every extension need this
trick.

							matz.

In This Thread

Prev Next