David A. Black wrote:
> I wouldn't want to see 'extend' start to mean both adding a module to
> the lookup path, and adding methods to the singleton class, depending
> on the context. I guess obj.extend do ... could create an anonymous
> module, though I've never had an issue with just creating it with
> Module.new or using a named module.

Ah, sorry I wasn't more clear. Yes, I meant it would create an anonymous 
module, so as to promote good coding practices. And I agree, it isn't 
that hard to use Module.new or name the module, nevertheless we see the 
singleton being used directly far too often b/c it is more convenient, 
even when having to define our own #singleton_method. And that's the 
point of the suggestion, to make it more convenient to #extend rather 
than #class_eval on the singleton class. Indeed (I wish I could find 
that article) one can make a good case that the singleton class should 
never have methods directly defined in it; always use a module.

T.
-- 
Posted via http://www.ruby-forum.com/.