I haven't done a lot of Ruby lately, and I don't know what the `NameSpace`-class is intended to be used for, but is the effect of the suggestion similar to that of https://github.com/hannestyden/require-here ?
It's intended to be used as a scope within which the default attachment point for constants is not the Object class but instead the `NameSpace` instance that the `require` call was made on.
Most people are talking about how this would allow you to require multiple versions of the same library (each in its own NameSpace), but I think that would be a bad use of it. I don't remember the last time I had a problem with conflicting libraries in Ruby, and I think the last time I did I just forked the offending library.
A more interesting use case is to have a framework like Rails use it to define namespaces for files without those files having to constantly refer to the name of the namespace they're in. That's something that's bugged me anyway.
Scoping module references has been a pain point in ruby since 1.0. Glad to see the community producing some solutions to the issue.
Curious to see how Namespace will work in practice with all the metaprogramming that's so common in popular Ruby libraries. I can also see this enabling applications to use multiple versions of the same library or module, for better or worse.
5 comments
[ 2.8 ms ] story [ 23.6 ms ] threadMost people are talking about how this would allow you to require multiple versions of the same library (each in its own NameSpace), but I think that would be a bad use of it. I don't remember the last time I had a problem with conflicting libraries in Ruby, and I think the last time I did I just forked the offending library.
A more interesting use case is to have a framework like Rails use it to define namespaces for files without those files having to constantly refer to the name of the namespace they're in. That's something that's bugged me anyway.
Curious to see how Namespace will work in practice with all the metaprogramming that's so common in popular Ruby libraries. I can also see this enabling applications to use multiple versions of the same library or module, for better or worse.