[ruby-core:124738] [Ruby Feature#6478] BasicObject#__class__
Issue #6478 has been updated by Eregon (Benoit Daloze). byroot (Jean Boussier) wrote in #note-18:
I mean, it's consistent with `__send__` and `__id__`, aliases of `send` and `object_id` meant to be used by generic code that want to ensure it can deal with any object, even ones that would redefine common methods.
Yeah, I dislike those too 😅 Specifically I think it looks very unidiomatic (and ugly) when used in Ruby code. I think at least it's clear it's not good to go towards having every `Kernel` method as a `__x__` variant on BasicObject. Also even `__send__` and `__id__` can be redefined, so the `KERNEL_CLASS = Kernel.instance_method(:class); KERNEL_CLASS.bind_call(obj)` approach is in fact safer. So my take on this is `KERNEL_CLASS = Kernel.instance_method(:class); KERNEL_CLASS.bind_call(obj)` is good enough, and also most BasicObject subclasses should implement Kernel-like methods. Concrete examples from real code where this is not good enough would most likely be helpful to move this forward if people want that. ---------------------------------------- Feature #6478: BasicObject#__class__ https://bugs.ruby-lang.org/issues/6478#change-116339 * Author: trans (Thomas Sawyer) * Status: Feedback * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- How else is one supposed to get the class of a subclass of BasicObject? -- https://bugs.ruby-lang.org/
participants (1)
-
Eregon (Benoit Daloze)