From: "Chr. Rippel" Date: 2002-01-10T04:01:47+09:00 Subject: Re: class name reported differently in different contexts "ts" wrote .... > Like I've said previously > > >> Well, for me this is not a technical problem. > > i.e don't give technical solution for a problem which is not technical > > :-)) Besides making a fool of myself by playing the devils advocate, I do find your answer very reasonable and satisfactory. One should not be too hang up about the value of Class#inspect anyway class A;end B = A class Object const_remove :A end class A; end p B,A, B == A # => A, A, false. Not owning a magic device to peek into the brain of Matz;-( still looking for a sale;-) I would probably find alternate (non)technical (explanations) solutions just as reasonable - e.g. calling #inherited before the new block infrastructure and setting the classid and classpath. Thanks, /Christoph ------ # This is my final non-solution;-) playing around with the new block # infrastructure.. def __correct_name (name,up = Object,context = Object, &body) res = Class.new up do |k| context.const_set name, k k.inspect context.send :remove_const, name end context.const_set name, res res.module_eval(&body) if block_given? res end alias correct_name __correct_name class Module private def correct_name(name,up = Object,&body) __correct_name(name,up,self,&body) end end # example class Base def Base.inherited(sub) puts "In #inherited, subclass name is #{sub}" raise "bad" end end module Mod correct_name :Sub, Base do puts "don't get here" end end rescue module Mod class A < Base;end end rescue puts "before GC.start" ObjectSpace.each_object(Class) do |k| puts k if k < Base end puts "after GC.start" GC.start ObjectSpace.each_object(Class) do |k| puts k if k < Base end ------ In #inherited, subclass name is Mod::Sub In #inherited, subclass name is A before GC.start Mod::Sub A after GC.start ------