From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS24940 94.130.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9230F1F5A0 for ; Thu, 9 Feb 2023 08:03:02 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=eczJNPaH; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=TZklx81E; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 18E9F7F0D6; Thu, 9 Feb 2023 08:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1675929775; bh=fSkIr4o8qLdqa+qZdbGnx/LSldNj0EtyVBsO/hQKKSU=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=eczJNPaH1BcqN33sZk31VG3P+i61MClU5tD9L0ra0qbiImV7IsXaN/J9nNtzmyauz 0B7MyvIXalhLGTWlQMTX/26TDJ1exwQqWc4lNuJYba+9V+YBrxng/yMVX8v1BTDLMf XeS6bboLwft3DFFfABh4MRaHhMY6RDj+/W+CrVtI= Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 426467F0C2 for ; Thu, 9 Feb 2023 08:02:50 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=TZklx81E; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=sCjU4yFoiCPiNSiOl7svMSoPtmwa7BW8rL/qdrV9wGU=; b=TZklx81EBtxA2VRyms9vNh/ngebcL5EA28coK8Rh6GQ/4GXZLIf4gSbIdtgA5+VOnFAD DgUtVpLS77v4u6oIe3IP4PxpglAD+bwOxOwhHEZI59uuXcO8C+8LjgYJz7oKC2XqrZR8PL pbaVHzgKfInC76/fy5CP1QGFvhI2jKRmw5uQWGamRc0y/t3C5wwCRSImMToXH9+oJjJyr/ 0nJJac84zHhAsItp1CIzTUCEdEQFG2VXolGgZKyRgylHLzxDgisx1x4NDE2r5XlInWGuwY LahKCNimNdQ8PDln10x9By0qur6vYSZvdC6+hA4bNWy/DlRFk9NU4XvuRfbElvqA== Received: by filterdrecv-6f5868ff54-b5qcb with SMTP id filterdrecv-6f5868ff54-b5qcb-1-63E4A8A8-17 2023-02-09 08:02:48.457163165 +0000 UTC m=+5990555.354559521 Received: from herokuapp.com (unknown) by geopod-ismtpd-6-2 (SG) with ESMTP id -M_F6KibQbCMBbUZqhm29w for ; Thu, 09 Feb 2023 08:02:48.398 +0000 (UTC) Date: Thu, 09 Feb 2023 08:02:48 +0000 (UTC) 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: shioyama 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: 88683 X-SG-EID: =?us-ascii?Q?2eXjFJg7SJ5y3z7=2FYZLzXiX0MH8ZxaRPe+ZjMibzxKHc16mJTtFOJX09zPdTSg?= =?us-ascii?Q?i7RAdHtyRFyjpk4L96iTT9m5Mpw0LXz5lR9wlty?= =?us-ascii?Q?qBqkXmEZWkmGy2R6pfVfZVx1PfknHu0X4gtTJS9?= =?us-ascii?Q?D3bRzZMFPiDR58URW4ax4fAAEbR6qqvnXVlbdI0?= =?us-ascii?Q?jY2m42IsFv6Pz15j46LYupM2qQy+joaDJFAalY=2F?= =?us-ascii?Q?=2FDDracJKse6Q4GZB7L+zrOpHHEKsq2Kkc1FVGqq?= =?us-ascii?Q?EW6Kpo5ZwJ17ZYuK+3fog=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: SBMPVDBQRY3CVRE2YZECXXWVMSRTYEZ5 X-Message-ID-Hash: SBMPVDBQRY3CVRE2YZECXXWVMSRTYEZ5 X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:112295] [Ruby master Feature#17753] Add Module#namespace List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "shioyama (Chris Salzberg) via ruby-core" Cc: "shioyama (Chris Salzberg)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #17753 has been updated by shioyama (Chris Salzberg). > When you assign an integer to a constant, it's just storage. If you assign a class or module object with a name, it's just storage. However, assigning an anonymous class or module object changes the state, it has a side-effect that is only programmed for these objects. That's a very interesting way to put it, I hadn't thought of it that way. And indeed those side-effects scale with the number of other classes and modules rooted in the thing that was named. ---------------------------------------- Feature #17753: Add Module#namespace https://bugs.ruby-lang.org/issues/17753#change-101730 * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/