From: ahoward Date: 2002-12-14T02:51:03+09:00 Subject: Re: Inheritance Question On Sat, 14 Dec 2002, ts wrote: G> >>>>> "a" == ahoward writes: G> G> G> a> for instance, if all calls to Matrix.method made from inside Matrix instance G> a> methods are replaced with type.method - Matrix works identically and becomes G> a> inheritable. G> G> Matrix is inheritable : the problem is with delegation require 'matrix' #the problem class MyMatrix < Matrix end mm = MyMatrix[ [42] ] p mm.type # >> MyMatrix p mm.to_f.type # >> Matrix #the fix class Matrix def collect rows = @rows.collect{|row| row.collect{|e| yield e}} #Matrix.rows(rows, false) type.rows(rows, false) end end mm = MyMatrix[ [42] ] p mm.type # >> MyMatrix p mm.to_f.type # >> MyMatrix i thinks it's a problem when you inherit from a class and cannot re-use the instance methods when they 'jump' outside the inherited class... eg. the only way around this is to completely rewrite evey Matrix instance method which refers to a Matrix class method. technically this IS inheritable but it's a bitter pill to swallow... -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================