ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:103044] [Ruby master Feature#17753] Add Module#outer_scope
@ 2021-03-26 19:19 tenderlove
  2021-03-27  7:58 ` [ruby-core:103053] " sawadatsuyoshi
                   ` (29 more replies)
  0 siblings, 30 replies; 31+ messages in thread
From: tenderlove @ 2021-03-26 19:19 UTC (permalink / raw)
  To: ruby-core

Issue #17753 has been reported by tenderlovemaking (Aaron Patterson).

----------------------------------------
Feature #17753: Add Module#outer_scope
https://bugs.ruby-lang.org/issues/17753

* 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)


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2023-02-10  0:49 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 19:19 [ruby-core:103044] [Ruby master Feature#17753] Add Module#outer_scope tenderlove
2021-03-27  7:58 ` [ruby-core:103053] " sawadatsuyoshi
2021-03-27 11:33 ` [ruby-core:103057] " eregontp
2021-03-27 21:51 ` [ruby-core:103065] " tenderlove
2021-03-28  6:05 ` [ruby-core:103069] " sawadatsuyoshi
2021-03-28 13:33 ` [ruby-core:103072] " jean.boussier
2021-04-10 10:35 ` [ruby-core:103371] [Ruby master Feature#17753] Add Module#namespace fxn
2021-04-10 10:54 ` [ruby-core:103372] " fxn
2021-04-10 20:45 ` [ruby-core:103382] " fxn
2021-04-12 15:28 ` [ruby-core:103405] " tenderlove
2021-04-12 17:29 ` [ruby-core:103409] " eregontp
2021-04-13  9:29 ` [ruby-core:103417] " fxn
2021-04-13  9:37 ` [ruby-core:103418] " fxn
2021-04-13  9:46 ` [ruby-core:103419] " fxn
2021-04-13 10:01 ` [ruby-core:103420] " fxn
2021-04-13 10:57 ` [ruby-core:103422] " eregontp
2021-04-13 11:50 ` [ruby-core:103424] " fxn
2021-04-13 16:35 ` [ruby-core:103433] " fxn
2021-04-17  7:27 ` [ruby-core:103493] " mame
2021-04-17  8:04 ` [ruby-core:103496] " fxn
2022-07-01  6:52 ` [ruby-core:109108] " ioquatix (Samuel Williams)
2022-07-01 16:13 ` [ruby-core:109111] " sawa (Tsuyoshi Sawada)
2022-07-02  0:03 ` [ruby-core:109112] " ioquatix (Samuel Williams)
2022-07-02  5:01 ` [ruby-core:109114] " sawa (Tsuyoshi Sawada)
2022-07-03 23:41 ` [ruby-core:109129] " ioquatix (Samuel Williams)
2022-07-04  1:42 ` [ruby-core:109131] " austin (Austin Ziegler)
2023-02-08  3:41 ` [ruby-core:112273] " shioyama (Chris Salzberg) via ruby-core
2023-02-08  7:54 ` [ruby-core:112277] " fxn (Xavier Noria) via ruby-core
2023-02-08 10:01 ` [ruby-core:112285] " fxn (Xavier Noria) via ruby-core
2023-02-09  8:02 ` [ruby-core:112295] " shioyama (Chris Salzberg) via ruby-core
2023-02-10  0:48 ` [ruby-core:112316] " shioyama (Chris Salzberg) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).