From: Rick DeNatale Date: 2006-08-31T08:26:45+09:00 Subject: Re: Obtaining a reference to an enclosing class of a nested class But module nesting is namespace nesting, so what does it mean to put a nameless object in a namespace? On 8/30/06, Logan Capaldo wrote: > > On Aug 30, 2006, at 6:10 PM, Joel VanderWerf wrote: > > > Logan Capaldo wrote: > >> On Aug 30, 2006, at 4:22 PM, Joel VanderWerf wrote: > >>> > >>> However, you say the classes are anonymous. How are you getting B > >>> under > >>> the scope of A in that case? > >>> > >> mod1 = Module.new > >> mod2 = nil > >> mod1.module_eval{ mod2 = Module.new } > > > > I don't think mod2 is nested in mod1, in any sense. There's no > > reason for ruby to keep track of the modules that are created > > during the execution of the block that accompanies the > > mod1.module_eval call and to associate them with mod1. The only > > reason B is associated with A in > > > > module A > > module B; end > > end > > > > is that they are lexically related. (More precisely the constant > > "B" is in the namespace belonging to the class A.) > > > > Maybe someone else has a more definitive answer? > > > > VALUE rb_define_module_under(VALUE outer, const char *name) > > You could use this to define a named module under an anonymous module. > > > -- > > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 > > > > > -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ IPMS/USA Region 12 Coordinator http://ipmsr12.denhaven2.com/ Visit the Project Mercury Wiki Site http://www.mercuryspacecraft.com/