Repository navigation
Do not pollute the global namespace - #7200
BertramScharpf wants to merge 1 commit into
Conversation
|
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
|
What's your issue? |
It's not a technical problem. It's a matter of style. My understanding of good programming style is to leave with a clean global name space. |
martinemde
left a comment
There was a problem hiding this comment.
I understand your concern is that a gem executable could not rely on str or version being unaltered in the top level namespace. You would need to compensate for this if you had a very strict need. However given that this is a critical path for every gem executable, I would suggest we need a better reason for changing it than style alone.
| if ARGV.first =~ /\\A_(.*)_\\z/ | ||
| str = $1 | ||
| if Gem::Version.correct?(str) |
There was a problem hiding this comment.
This code is not strictly equivalent to the original code. I don't know with certainty that it would cause any problem, but this is a critical path for almost everything in ruby.
Accidentally submitted approve when I meant to comment.
|
I'm going to close this for now. The two proposed solutions, tap, and evaling within a module, affect the stack in unfavorable ways, imho, and solve for something that we don't think is a problem. I'm open to this issue being raised again if there's a concern or a case where this is a problem. |
Inside a Gem executable you get:
This is not fair.
I decided to propose an
Object#tapcall because defining a function would polluteTOPLEVEL_BINDING.private_methods.Maybe an even better way to solve the problem is to put the variable assignments and usage into a
module Gem ; ... ; endblock.