[#57574] [ruby-trunk - Feature #8976][Open] file-scope freeze_string directive — "akr (Akira Tanaka)" <akr@...>

70 messages 2013/10/02

[#57579] [ruby-trunk - Feature #8977][Open] String#frozen that takes advantage of the deduping — "sam.saffron (Sam Saffron)" <sam.saffron@...>

25 messages 2013/10/02

[#57679] [ruby-trunk - Feature #8987][Open] map/collect extension which handles arguments — "sowieso (So Wieso)" <sowieso@...>

16 messages 2013/10/05

[#57705] [ruby-trunk - Feature #8992][Open] Use String#freeze and compiler tricks to replace "str"f suffix — "headius (Charles Nutter)" <headius@...>

43 messages 2013/10/07

[#57727] [ruby-trunk - Feature #8998][Open] string keys for hash literals should use fstrings — "normalperson (Eric Wong)" <normalperson@...>

17 messages 2013/10/08

[#57771] [ruby-trunk - Bug #9008][Open] TestProcess#test_clock_getres_constants and TestProcess#test_clock_gettime_constants fails on ARM — "vo.x (Vit Ondruch)" <v.ondruch@...>

15 messages 2013/10/09

[#57888] [ruby-trunk - Feature #9025][Open] Clarify the error message when calling a method with the wrong number of arguments — Nerian (Gonzalo Rodríguez) <siotopo@...>

11 messages 2013/10/15

[#57993] [ruby-trunk - Feature #9047][Open] Alternate hash key syntax for symbols — "jamonholmgren (Jamon Holmgren)" <jamon@...>

13 messages 2013/10/23

[#58007] [ruby-trunk - Feature #9049][Open] Shorthands (a:b, *) for inclusive indexing — "mohawkjohn (John Woods)" <john.o.woods@...>

25 messages 2013/10/24

[#58033] [ruby-trunk - Bug #9053][Open] SSL Issue with Ruby 2.0.0 — "tisba (Sebastian Cohnen)" <ruby-lang@...>

16 messages 2013/10/25

[#58080] [ruby-trunk - Feature #9064][Open] Add support for packages, like in Java — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

23 messages 2013/10/30

[ruby-core:58101] [ruby-trunk - Feature #9064] Add support for packages, like in Java

From: "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>
Date: 2013-10-31 14:30:10 UTC
List: ruby-core #58101
Issue #9064 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


david_macmahon (David MacMahon) wrote:

>...  If we change the behavior, then the implicit creation of module MyModule and module MyModule::MyClass and module MyModule::MyClass::InnerModule will "work", but then any subsequent attempt to create class MyModule::MyClass will fail loudly...

What I was trying to say is that MyClass will be a different object depending on the order you require 'my_module/my_class/inner_module' unless this file explicitly requires 'my_module/my_class' before defining InnerModule. If this is not the case, you would get no error in your application if it first requires MyClass and then InnerModule. But if for some reason inner_module is loaded first at some point, things will break later when you require MyClass. Currently it will break as soon as you require InnerModule without requiring MyClass first...

I'm particularly not worried about this behavior since I always opt for explicit in my applications and it doesn't matter at all the order in which my files are required since they would always behave the same way. But since this is not a common practice in the Ruby community I think the Ruby core team might be worried about this behavior change...
----------------------------------------
Feature #9064: Add support for packages, like in Java
https://bugs.ruby-lang.org/issues/9064#change-42689

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/

In This Thread