From: Robert Klemme Date: 2003-08-07T00:02:40+09:00 Subject: Re: newbie question from a smalltalker "Mark Wilson" schrieb im Newsbeitrag news:5DE47352-C818-11D7-93B4-000393876156@cox.net... > > On Wednesday, August 6, 2003, at 09:02 AM, Adriano Volpones wrote: > > > Dear all, > > > > I am a seasoned Smalltalk developer and I'm playing with Ruby which I > > found > > the best script language in the spirit of Smalltalk. > > > > What I cannot find in it is the entire world of programming and > > refactoring > > tools that are for long time available in every Smalltalk environment. > > > > For example the simple list of "implementors" and "senders" of a > > method is > > invaluable when the project begins to grow up to hundreds of classes. > > [snip] > > I hope that you can put together a list of the tools you would like to > see in Ruby from your perspective based on experience with Smalltalk. > > It should be possible to create a list of implementors and senders of a > method using the ObjectSpace module and each object's built-in > introspection methods (class, respond_to?, methods, > methods.include?(), etc.). Yep, apart from the fact that you won't find the senders - which is a quite important thing to know. The closes you can get is a script that wades through the sources and prints out all occurrences of "."; you would only miss those cases where some instance invokes the method on itself - but these are easy to find anyway. Other than that it'll be difficult because of the dynamic typing of the language. You can't determine from "foo.size()" whether it's the size method of class Array or String - which is a bit of a difference. Regards robert Just some code to play with in IRB: def implementors(sym, type=nil) sym = sym.intern if sym.kind_of? String if type.nil? ObjectSpace.each_object() do |obj| p obj if obj.respond_to? sym end else ObjectSpace.each_object( type ) do |obj| case type when Class, Module begin inst = obj.new p obj if inst.respond_to? sym rescue # ignore end else p obj if obj.respond_to? sym end end end end