From: "ko1 (Koichi Sasada) via ruby-core" Date: 2023-03-10T05:42:50+00:00 Subject: [ruby-core:112822] [Ruby master Feature#19452] `Thread::Backtrace::Location` should have column information if possible. Issue #19452 has been updated by ko1 (Koichi Sasada). Let me clear why column information is better than `node_id` My understanding: * Better than `node_id` * B1. We can get one column information (maybe most wider information, for example: `a.b.c.d.func(...)` for `func()`. * B2. We can get (maybe) corresponding node by column information. not exact same with `node_id` but similar. * B3. Column information is not magical than `node_id` * B4. Can detect file modification on reparsing (not all modification though) because we can not get corresponding node by column information. * Worse than `node_id` * W1. More memory consumption * W2. Can not get exact corresponding node with column information because some nodes can have same column information. * W3. Can not get corresponding node on reparsing when the script was modified, even if spacing or commenting (<=> B4) * W4. (personal concern) if we introduce it, I'm afraid that people ask to hold more and more information than the column information * Both worse * S1. Need to reparse a script and analyze the script to get more information like method name, parameters and so on. ---------------------------------------- Feature #19452: `Thread::Backtrace::Location` should have column information if possible. https://bugs.ruby-lang.org/issues/19452#change-102329 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- I discussed this with @mame and it would be pretty useful if we could also get the column information from exception backtrace location, even if it was slow. A POC: ```ruby class Thread::Backtrace::Location if defined?(RubyVM::AbstractSyntaxTree) def first_column RubyVM::AbstractSyntaxTree.of(self, keep_script_lines: true).first_column end else def first_column raise NotImplementedError end end end ``` It would be good to have a standard interface, so we follow the same interface as https://bugs.ruby-lang.org/issues/19451 and vice versa where it makes sense. I'll investigate it. -- 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/