Project

General

Profile

Actions

Feature #12138

closed

Support `Kernel#load_with_env(filename, cbase: SomeMod, cref: someMod, binding: SomeMod) # => obj`

Added by josh.cheek (Josh Cheek) about 8 years ago. Updated over 7 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:74101]

Description

Ruby's require and load methods currently only return true, which means that any code being loaded must affect the global namespace, or have the global namespace affected for it to interact with.

This means that to load data, like a gemspec, you have to read the file in and eval it:

To load a plugin or configuration, you have to modify a global object:

It's why gems have to be built the way they do, to avoid colliding with other code in the global namespace (fwiw, I've seen a computer segfault when the person unwittingly write their own Queue class). Which is also why we can't load multiple versions of a gem in the same namespace.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0