From: Sean O'Dell Date: 2004-06-09T05:50:46+09:00 Subject: Re: [ANN] Ruby/Interface On Tuesday 08 June 2004 13:23, Mauricio Fern�ndez wrote: > On Wed, Jun 09, 2004 at 03:46:30AM +0900, Sean O'Dell wrote: > > Ruby/Interface tries to solve this problem by ???tagging??? objects as > > implementing an interface. The implementation is enforced by comparing an > > object???s methods against the methods expected by the interface. > > Some comments: > > I see you're using per-class tagging, hence being unable to track > changes in the singleton class. I'd point you again to the last sections > of http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555 > which I believe you didn't read. > There's an inconsistency in the code: you're checking the methods of the > object (including its singleton methods) with Object#method but storing > the result in a per-class structure; that won't fly. > > Also, using class variables instead of class instance variables ties the > notion of interface to inheritance, which I believe you wanted to avoid. > > I would consider storing the conformance information in > ROBJECT(self)->klass directly; this will be either the real class or > the singleton class. In the first case, the "conformity table" is > shared by all objects of that class; in the second, it will be "owned" > by the object. The advantage is that this new table would be created > on demand, only when the object is extended/a singleton method is > defined and has_interface? is called. You wouldn't even need to capture > singleton_method_added this way. I have to ponder this a bit. I admit I am not entirely clear how Ruby works internally, and singletons are something I don't quite get. Let me digest the suggestions. Sean O'Dell