From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 05C081F4B4 for ; Sat, 17 Apr 2021 07:27:35 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 70781120E7B; Sat, 17 Apr 2021 16:26:32 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 82975120A8A for ; Sat, 17 Apr 2021 16:26:30 +0900 (JST) Received: by filterdrecv-7cd54bd647-v6xhs with SMTP id filterdrecv-7cd54bd647-v6xhs-15-607A8DE1-24 2021-04-17 07:27:29.690203645 +0000 UTC m=+126365.952758932 Received: from herokuapp.com (unknown) by ismtpd0154p1iad2.sendgrid.net (SG) with ESMTP id hurSQw5tTfWrZqR9pDNV8A for ; Sat, 17 Apr 2021 07:27:29.681 +0000 (UTC) Date: Sat, 17 Apr 2021 07:27:29 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17753 X-Redmine-Issue-Author: tenderlovemaking X-Redmine-Sender: mame X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 79540 X-SG-EID: =?us-ascii?Q?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb4=2FJKZb3u0ztBjoiVORJqo?= =?us-ascii?Q?YTBBugYrP4rf0LPRZiV3fLzxKCpuKr3GND35=2FAS?= =?us-ascii?Q?J1ff=2Fo+wsgrdmvE85Mp5Js2t4s5YOGze=2FkuNTe7?= =?us-ascii?Q?l=2FLwCvUk3FuqY9BeduoxtN5isnd9UIk6PTqQzFK?= =?us-ascii?Q?YntaN1aDpP9tskigEZ1SZ5YZ+1BHsgHpigA=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103493 Subject: [ruby-core:103493] [Ruby master Feature#17753] Add Module#namespace X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17753 has been updated by mame (Yusuke Endoh). This ticket was discussed on the dev meeting. @matz said that (1) the use case is not clear to him, and that (2) he wants to keep the keyword `namespace` for another feature in future. `outer_scope` is also weird because the return value is not a "scope". ---------------------------------------- Feature #17753: Add Module#namespace https://bugs.ruby-lang.org/issues/17753#change-91589 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Priority: Normal ---------------------------------------- Given code like this: ```ruby module A module B class C; end class D; end end end ``` We can get from `C` to `B` like `C.outer_scope`, or to `A` like `C.outer_scope.outer_scope`. I want to use this in cases where I don't know the outer scope, but I want to find constants that are "siblings" of a constant. For example, I can do `A::B::C.outer_scope.constants` to find the list of "sibling" constants to `C`. I want to use this feature when walking objects and introspecting. For example: ```ruby ObjectSpace.each_object(Class) do |k| p siblings: k.outer_scope.constants end ``` I've attached a patch that implements this feature, and there is a pull request on GitHub [here](https://github.com/ruby/ruby/pull/4326). ---Files-------------------------------- 0001-Add-Module-outer_scope.patch (5.93 KB) 0001-Add-Module-namespace.patch (5.89 KB) -- https://bugs.ruby-lang.org/