[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

Re: class= and type checks when casting

From: "Sean O'Dell" <sean@...>
Date: 2004-06-26 01:16:56 UTC
List: ruby-core #3092
On Friday 25 June 2004 18:08, nobu.nokada@softhome.net wrote:
>
> Sean O'Dell wrote in [ruby-core:03090]:
> > Matz, I'm not sure if you followed the discussion in ruby-talk about
> > having a "class=" method.  We were just talking about changing the class
> > of an object, and what problems would/would not arise in so doing.  When
> > I tried implementing "class=" on my own, Ruby crashed pretty badly in a
> > lot of places.  Then I realized the reason was because so much code casts
> > VALUEs to RFILE, RHASH, etc. without checking that the types were
> > actually valid.  So I changed many of the casts in ruby.h (RHASH, RFILE,
> > RSTRING, etc.) to perform a quick type check.  That solved the problem of
> > crashing the built-in types when the class was changed.  I ran some
> > tests; 100,000x calling file#read with and without checking that the file
> > object's class was truly T_FILE, and I noticed no time difference.  I
> > don't think the extra check adds any noticable overhead.
>
> That comparison using I/O wouldn't be accurate.

I figured there would be other problems.

> First of all, why do you want to do it, and what do you want to
> do by it?

No particular reason in the immediate.  It just came up during a thread in 
ruby-talk and I realized it was possible, so I gave it a try.  It works 
pretty well, but I'm sure more steps could be taken to further bullet-proof 
the feature.

	Sean O'Dell

In This Thread