Feature #6210
closed
load should provide a way to specify the top-level module
Added by now (Nikolai Weibull) over 12 years ago.
Updated about 3 years ago.
Description
load currently takes an optional second argument that allows you to load into an anonymous and new top-level Module. It would be nice if the second argument could also be a Module that would then be used as the top-level Module. That way one could provide a set of methods that should be available to the content being loaded without having to put them in Kernel.
- Assignee set to matz (Yukihiro Matsumoto)
- Target version set to 2.0.0
Sounds partially like #5643?
- Status changed from Open to Assigned
- Target version changed from 2.0.0 to 2.6
I changed target to next minor because no discussion on it.
- Target version deleted (
2.6)
Agreed, it could be used to experiment with new ways to load code in a non global manner.
That being said it would entirely sidestep iseq caching. Not that it's a deal breaker, but if this were to be used for loading lots of code, we might also need RubyVM::InstructionSequence#eval(wrapping_module)
OK, I (finally) accepted the proposal. Go ahead.
Matz.
- Status changed from Assigned to Closed
Applied in changeset git|b35b7a1ef25347735a6bb7c28ab7e77afea1d856.
Allow Kernel#load to load code into a specified module
Instead of always using a new anonymous module for Kernel#load if
the wrap argument is not false/nil, use the given module if a module
is provided.
Implements [Feature #6210]
What about the RubyVM::InstructionSequence
was there any discussion to allow caching Kernel.load(path, module_instance)
?
byroot (Jean Boussier) wrote in #note-9:
What about the RubyVM::InstructionSequence
was there any discussion to allow caching Kernel.load(path, module_instance)
?
The dev meeting log does not indicate this was discussed. If you think it's important, can you add it as a new feature request?
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0