From: matz@... (Yukihiro Matsumoto) Date: 2001-12-31T00:59:00+09:00 Subject: [ruby-talk:29728] Re: extending method of class A to support arguments of class B by promoting `self' to class B Hi, In message "[ruby-talk:29700] Re: extending method of class A to support arguments of class B by promoting `self' to class B" on 01/12/30, Tomasz Wegrzanowski writes: |> Define "such thing". And convince me it's nice. | Such-thing is defined more by problem it tries to solve than by solution. But it's within Numeric hierarchy, where coerce mechanism is available, for that particular purpose. I'm not sure there's need for generic coerce-like system. Some basic types such as Array, String, Integer, and IO have corresponding conversion methods, "to_ary", "to_str", "to_int", and "to_io" respectively. But there's no generic system. | Such-thing could be based on TypeError exception mechanism. Unfortunately the current implementation of Ruby's exception is not resumable. Generalize "to_str" etc. might be better way, but I think it's hard to generalize them. matz.