--8323328-1989049411-1122484267734 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1989049411-1122484267=:4734" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1989049411-1122484267734 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 28 Jul 2005, Daniel Brockman wrote: > Hmm, for some reason this part of your message was left out > of my reply buffer, so I forgot to reply to it! > > "Ara.T.Howard" <Ara.T.Howard / noaa.gov> writes: > >>>> That's not instantiating a module. It's cute, but it's >>>> not instantiating a module. >>> >>> Of course it's not instantiating a module, but it's >>> pretty much _as good as_ instantiating a module. It lets >>> you use modules instead of classes, which demonstrates >>> that the distinction is superficial. >> >> does it? >> >> [Complicated way of saying module.new.class != module.] > > As I trust you are already aware, that's easily fixed: > Just redefine the lassmethod to return the module. yes - just pointing out there's more to being a class than having a new method... >> and, of course, you still can't inherit from M - but i >> realize this needed be so. > > Yes, you can: > > module N > include M > end the problem is a bit deeper than that and stem from the fact that includingodule does not inject the included modules singleton methods into the 'includee'. for example (note this has the fix suggested above): harp:~ > cat a.rb class Module def new(*a, &b) (@__klass__ ||= (m = self and Class::new{ include(@@m = m); def class;@@m;end }))::new(*a, &b) end end module M class << self def class_method 42 end end def instance_method 42 end end module N include M end begin m = M::new p m.class p m.instance_method p m.class.class_method rescue => e puts "#{ e.message } (#{ e.class }" end begin n = N::new p n.class p n.instance_method p n.class.class_method rescue => e puts "#{ e.message } (#{ e.class }" end harp:~ > ruby a.rb M 42 42 N 42 undefined method `class_method' for N:Module (NoMethodError i'm not saying it's not possible - just that it's a bit more work than you're suggesting. doing things consistently at an object, class, module, and singleton_class level gets very confusing very quicky - just check out the code for my traits lib to see just how. ;-) i personally often get around this detail by module M module ClassMethods end module InstanceMethods end include InstanceMethods self.extend ClassMethods def self::included other class << other include InstanceMethods end other.extend ClassMethods end end or something similar - in otherwords factor out class methods so that can be added individually to other classes/modules when they are included there. thus begins the trickiness... (ps. for some reason the charset from your message is very odd - it may be on my end but thought you might like to know. it looks like some sort of escape chars around '@' signs - coloring?) cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso =============================================================================== --8323328-1989049411-1122484267734-- --8323328-1989049411-1122484267734--