[ruby-core:114238] [Ruby master Feature#19775] Use the callback `main::const_added`

Issue #19775 has been reported by UlyssesZhan (Ulysses Zhan). ---------------------------------------- Feature #19775: Use the callback `main::const_added` https://bugs.ruby-lang.org/issues/19775 * Author: UlyssesZhan (Ulysses Zhan) * Status: Open * Priority: Normal ---------------------------------------- In #17881, it was accepted that `Module#const_added` is called when there is a new constant added to the namespace of the module. Since `main` can also serve as a namespace, it should also be able to use this callback. ```ruby def const_added name p name end Foo = 1 # => :Foo ``` -- https://bugs.ruby-lang.org/

Issue #19775 has been updated by mame (Yusuke Endoh). Status changed from Open to Closed Since top-level constants are defined under Object, their definition can be hooked by defining `Object.const_added`. ```ruby def Object.const_added(name) p name end Foo = 1 #=> :Foo ``` ---------------------------------------- Feature #19775: Use the callback `main::const_added` https://bugs.ruby-lang.org/issues/19775#change-103925 * Author: UlyssesZhan (Ulysses Zhan) * Status: Closed * Priority: Normal ---------------------------------------- In #17881, it was accepted that `Module#const_added` is called when there is a new constant added to the namespace of the module. Since `main` can also serve as a namespace, it should also be able to use this callback. ```ruby def const_added name p name end Foo = 1 # => :Foo ``` -- https://bugs.ruby-lang.org/
participants (2)
-
mame (Yusuke Endoh)
-
UlyssesZhan (Ulysses Zhan)