From: "Eregon (Benoit Daloze) via ruby-core" Date: 2023-05-25T11:00:58+00:00 Subject: [ruby-core:113657] [Ruby master Feature#19644] Module::current to complement Module::nesting Issue #19644 has been updated by Eregon (Benoit Daloze). bughit (bug hit) wrote in #note-12: > Still, a single label identifier without arguments (like `__mod(ule)__`) looks better: `"#{__module__}##{__method__}"` Finally a concrete example (although partial): logging with `"#{__module__}##{__method__}"`. We asked many times, I am not sure why you waited so long to show this one. One can maybe guess what you want, but that is not productive and will not help the ticket, it will only waste time. At a developer meeting, or earlier, if there is no concrete use case, either the proposal will be skipped or closed (maybe as Feedback to reflect the lack of a convincing and concrete example, maybe Rejected for not following the template). It should have been part of the issue description as the [template](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToRequestFeatures) says. The template could be more explicit that an example with Ruby code is the most important, however this has already been mentioned to you in [here](https://bugs.ruby-lang.org/issues/10450#note-22) (and many other times) and is also what I meant by `This needs a concrete use case`. I'll improve the template in that direction. And of course ideally the template should be shown when opening a new feature, there have been discussions to do that. Now going to this example, there are two problems: * This means every time one wants to do tracing/logging like that, they cannot just use `LOGGER.info "message"`, they would need to use `LOGGER.info "#{__module__}##{__method__} message"`. That seems very inconvenient. Maybe you want to access the caller's module? That is a different proposal then. * This is confusing and incorrect if in a method inside class_exec/module_exec/instance_exec: ```ruby module Foo def self.setup(klass) klass.class_exec do def bar LOGGER.info "#{__module__}##{__method__} message" # incorrect, will show `Foo#bar`, but no such method was ever defined in this program end end end end Foo.setup(String) ``` So probably the default definee would be better for that. Of course it does not address the first point. Maybe you can realize now why I think this is closely related or a duplicate with #19682: * They both didn't have a concrete example, were filed closely in time, and are talking about related concepts, so the use case might mix both. * If the use case is logging, it seems you might want the default definee and not Module.nesting[0]. I also think it's of little practical value to have the module (and method) there. For the rare cases it'd be useful, one could just write the module name by hand to help tracing/debugging, or likely more useful words to identify that place (e.g. when printing in multiple places in a method). If you want to trace every method call that is also possible with TracePoint. The file and line can already be shown, and they can be queried for the caller, so `LOGGER.info "message"` can show `INFO: foo.rb:5 message` already today. That seems plenty and is more precise. Both of these issues are closed now, you can see I am not the only one which has a problem with such vague feature requests and the way you communicate. --- Now I want to reply to some of your disrespectful comments, because it may help you find a better way to communicate with others. So, apparently you are mixing both concepts of Module.nesting and default definee in this issue with the logging use case. But yet I am not going to harass you about it, I will say it here only once, without any pejorative adjective. In contrast, you keep claiming I don't know when [it's clear I know very well](https://github.com/oracle/truffleruby/commit/c5925bd54c00dc22bb5609e76aa3e2666b522d30). The fact you repeat it many times does not make it more true, nobody will be fooled by that, it is just more obvious you harass people and do not know how to communicate properly. Also you must realize that attacking everyone on this bug tracker like https://bugs.ruby-lang.org/issues/19682#note-26 is not productive and will not help your proposal, it will only help you get banned. If you think everyone is wrong, most likely it is not the case, probably you are misreading or misinterpreting what they said or you are wrong. In the future, and for the last time, do communicate as an adult, never harass or insult others, or leave this bug tracker/mailing list. Never use [Ad hominem](https://en.wikipedia.org/wiki/Ad_hominem), discuss and argue the substance, not the person. That also implies no pejorative adjectives in what you write. It might be a good idea to ask someone to review your replies before posting them to make sure they are appropriate. ---------------------------------------- Feature #19644: Module::current to complement Module::nesting https://bugs.ruby-lang.org/issues/19644#change-103299 * Author: bughit (bug hit) * Status: Rejected * Priority: Normal ---------------------------------------- Module::current == Module::nesting[0] but without needlessly walking the entire nesting hierarchy. Could be useful for debugging/logging. It could also be a Kernel global (like `__method__`) or a keyword (like `__FILE__`) -- 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/