From: David Alan Black Date: 2001-07-02T22:48:59+09:00 Subject: [ruby-talk:17145] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) Hello -- On Mon, 2 Jul 2001, ts wrote: > >>>>> "D" == David Alan Black writes: > > D> A followup question... how useful/used is Exception#exception? Maybe > D> I've just been staring at it too long :-) but I'm wondering what it > D> does that couldn't be done already. I notice it isn't used at all in > D> the distribution (plus whatever site_ruby stuff I've got): > > You have not made the good grep :-) > > pigeon% grep \"exception *.c > error.c: rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1); > error.c: rb_define_method(rb_eException, "exception", exc_exception, -1); > eval.c: exception = rb_intern("exception"); > eval.c: rb_raise(rb_eTypeError, "exception class/object expected"); > eval.c: rb_raise(rb_eTypeError, "exception object expected"); > pigeon% > > pigeon% less eval.c > [...] > exception = rb_intern("exception"); > if (!rb_respond_to(argv[0], exception)) { > rb_raise(rb_eTypeError, "exception class/object expected"); > } > mesg = rb_funcall(argv[0], exception, n, argv[1]); > break; True, my grep is a bit selective :-) But still, if the only reason #exception exists is to allow both: raise ExceptionClass and raise anException then I wonder whether it should perhaps be hidden -- that is, whether the test for valid argument to #raise should be internal to eval.c, and not resurface as a public instance method of Exception. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav