Issue #9064 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


When I talk about conflicts, I'm worried about an existing MyModule::MyClass in the project.

If you do "module MyModule::MyClass::InnerModule" without requiring the class first, it would create the MyClass constant as a module and then you would have different behavior depending on how you're requiring InnerModule.

Currently, it won't create MyClass as a module on demand, but will raise an exception instead and the developer will be warned about the mistake.

But if we change the behavior of "module" to make it create inexistent parent modules on demand it will then fail silently from current programmer expectation. This is what I refer to as backward incompatible.
----------------------------------------
Feature #9064: Add support for packages, like in Java
https://bugs.ruby-lang.org/issues/9064#change-42665

Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 


In Java, it's easy to define a package for a certain class:

package com.company.MyClass

We don't use that convention in Ruby but we have another way of packaging classes:

module MyLibrary
  module InnerNamespace
    class MyClass
    end
  end
end

I'd prefer to be able to use something like this instead meaning exactly the same thing:

package MyLibrary::InnerNamespace # or MyLibrary.InnerNamespace, I don't really care
class MyClass
end

Could you please consider this idea?


-- 
http://bugs.ruby-lang.org/