From: Logan Capaldo Date: 2006-08-31T07:41:21+09:00 Subject: Re: Obtaining a reference to an enclosing class of a nested class 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 >