3 ms·
Part of the problem is Ruby's hackish module system. When you include a module, you are taking everything, whether you like it or not. I have created a libra
by gregwebs 18y ago
Part of the problem is Ruby's hackish module system. When you include a module, you are taking everything, whether you like it or not.
I have created a library to help manage includes, and make them more like imports in other languages that have real modules. (You can selectively include methods from a module)
http://github.com/gregwebs/module-import/ http://github.com/gregwebs/module-import/
blog post
http://blog.thoughtfolder.com/2008-03-11-real-modules-for-ruby.html http://blog.thoughtfolder.com/2008-03-11-real-modules-for-ru...
If this used some of your ruby parsing magic to analyze dependencies, it would be a lot better.
- tptacek 18y agoI totally don't see how this is a win. The monkeypatch problem is that multiple people are competing for the same names on Fixnum, String, Array, Hash, and Object. To solve that problem, your code would need to allow a Fixnum to support Numeric#to_asn1 in my code, but pretend not to have it everywhere else.
- gregwebs 18y agoThis is not a solution to the problem, but it picks away at it. The goal of this is to prevent unnecessary namespace pollution. So if in your code you say class Object import MethodChain, :tap end You will never import MethodChain#chain or any other methods into Object, and you will never have to worry about re-writing those methods.