Hi,

In message "[ruby-talk:00609] Re: How to pass by `new' method of superclass ?"
    on 99/08/10, clemens.hintze / alcatel.de <clemens.hintze / alcatel.de> writes:

|> Do you really need inheritance relationship?  Current Ruby requires
|> instances of the subclass of IO to have T_FILE structure.
|
|I don't know really. I would like it, as there may be methods, that
|wants to get an `IO' or a `File' instance. `mailread.rb' comes in mind
|(I know it is fixed yet :-)

Well, but that was a typical exapmle of the bad OO design. :-<

|But perhaps if that happen, I could create a file on-the-fly, put the
|`StringIO' instance contents into it, and work forth as a normal file,
|which will be deleted after close.... :-/ That could be a good idea,
|couldn't it?
|
|Nevertheless, is there such a method to by-pass the `new' method of a
|parent?

Using C, yes, you can.  You just need to call NEWOBJ() macro.  But
remember all methods in IO (and File) require T_FILE structure.  If
you happen to forget to redefine even single method, it will cause a
serious problem.

|> The method I can think of receiving IO instance (T_FILE object) as
|> arguments is IO::select, which of cource can't handle StringIO.
|
|But it would use `fileno' and therefore I can create a file on-the-fly?
|If not, overwriting select should be enough, shouldn't it?

You can define (undocumented) `to_io' method instead of fileno for
select.  `to_io' method should return a object with T_FILE structure.

                                                        matz.