ES <ruby-ml / magical-cat.org> writes:

> On 2/19/2005, "Lloyd Zusman" <ljz / asfast.com> wrote:
>>
>> [ ... ]
>>
>>Actually, I now realize that I don't need a bona fide named module, but
>>rather, just a way to associate a name with a module.  Therefore, I
>>think that I can do it more or less like this:
>>
>>  modhash = Hash.new
>>  if fname then
>>    if modhash.has_key?(fname) then
>>      mod = modhash[fname]
>>    else
>>      mod = Module.new
>>      modhash[fname] = mod
>>    end
>>    data = File.new(fname, 'r') do |f|
>>             f.read
>>           end
>>    mod.module_eval data
>>    mod.send :init, args
>>  end
>>
>>Does this make sense?
>
> Yes, but I'm not sure if I understand why you're doing this in the
> first place. Why don't you just create a named module, store it in a
> file and load it when requested instead of just storing the code
> that'll go in the module?

Because I want to share code (via symbolic links) and associate it with
several modules, each module being named differently, based on the file
in which it resides.  Also, I may change the names of these files from
time to time, and when I do, I don't want to also have to remember to
also change the module names contained in these files.

By dynamically naming the modules in the ways we have been discussing,
this allows me to have a unique namespace for each file-based module
that I create, even if several files share the same contents via
symbolic links.  And this is ensured no matter how many renames
or symbolic link changes I make.

-- 
 Lloyd Zusman
 ljz / asfast.com
 God bless you.