From: matz@... (Yukihiro Matsumoto) Date: 2001-07-02T17:19:07+09:00 Subject: [ruby-talk:17138] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) Hi, In message "[ruby-talk:17079] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive)" on 01/06/30, David Alan Black writes: |> Question: does "clone" work for the latter? In other words, do you |> need exact same id for these exceptions, or just "equal" exception |> objects? FYI, instance variables and singleton methods are copied by |> clone operation. | |Yes, clone works, at least in the case(s) that I was playing with |(adding an attribute to NameError and wanting it to travel with the |object). So, how about making Exception#exception clones the receiver exception inside, instead of creating a exception object of the receiver's class. matz. --- error.c 2001/06/05 07:50:59 1.28 +++ error.c 2001/07/02 08:18:20 @@ -324,3 +324,3 @@ { - VALUE etype, exc; + VALUE exc; @@ -328,7 +328,3 @@ if (argc == 1 && self == argv[0]) return self; - etype = CLASS_OF(self); - while (FL_TEST(etype, FL_SINGLETON)) { - etype = RCLASS(etype)->super; - } - exc = rb_obj_alloc(etype); + exc = rb_obj_clone(self); rb_obj_call_init(exc, argc, argv);