Issue #15287 has been updated by ko1 (Koichi Sasada).


English naming question!



As I mentioned in commit log, I introduced the following two methods:

* `TracePoint#compiled_instruction_sequence` method to get compiled `RubyVM::InstructionSequence` instance.
* `TracePoint#compiled_eval_script` method to get compiled script (String) by `*eval` methods (return nil if compiling by file).


Matz agreed with `TracePoint#compiled_instruction_sequence` but has question about `TracePoint#compiled_eval_script`.

Both use prefix `compiled_` but we use two meanings: iseq is the result of compilation and `eval_script` is source string. The result and the source.

Is it natural or do we have better name?


----------------------------------------
Feature #15287: New TracePoint events to support loading features
https://bugs.ruby-lang.org/issues/15287#change-75544

* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 2.6
----------------------------------------
# Abstract

I propose the following new TracePoint events:

* `loaded` (invoked after `require`/`load`)
* `method_added` (invoked after method definition)

# Background

Sometimes we need to hook loading iseq. For example, checking loading files and so on.
Also we want to know what kind of methods are defined.

For both purpose, we can use some hook methods such as `Module#method_added` and so on.
However, defining methods we can override this features.
So that if we have two tools/libraries using this feature, they can be conflicted.

# Proposal

Introduce new TracePoint events:

* `loaded` (invoked after `require`/`load`)
* `method_added` (invoked after method definition)

Also the following methods can be added:

* Active only `loaded` event:
  * `TracePoint#loaded_feature` returns feature name.
  * `TracePoint#loaded_iseq` returns `RubyVM::InstructionSequence` object (MRI only, internal feature)

# Optional proposal

Add `class_added` alias name for `class` event.




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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>