Issue #15743 has been updated by Eregon (Benoit Daloze).


mame (Yusuke Endoh) wrote:
> If you think so, you have to implement the feature in any way, regardles of whether it is renamed to CRuby or not?  I don't see at all what the renaming will solve.

I think the rename will solve the problem of making it clear, wherever `RubyVM` is currently used, that it exists only on MRI, and is meant as a CRuby playground, rather than being some portable VM module between Ruby implementations.
It would also make it consistent with the JRuby, TruffleRuby and Rubinius modules.

> > * RubyVM::InstructionSequence is a representation of the MRI/CRuby/YARV bytecode. I don't think we can reproduce this on e.g., TruffleRuby, where there is no Ruby bytecode involved.
> > * RubyVM::AbstractSyntaxTree exposes the internal CRuby AST. I'm pretty sure other Ruby implementations have a slightly different AST while parsing. Ripper seems the portable version of this.
> 
> I believe that they can be implemented as compatibility layers.  For example, TruffleRuby's RubyVM::InstructionSequence can return a MRI-compatible bytecode, but TruffleRuby will not use the bytecode for execution.  I think that such a dummy API would be actually useful for some cases, e.g., MRI bytecode-level static analyzer.
> 
> You may think it is not worthy for implementation effort.  I agree.

Right, I guess it is theoretically possible but I think it wouldn't make much sense (using MRI for a MRI bytecode-level static analyzer makes more sense).
We could just have a dummy implementation returning a RubyVM::InstructionSequence instance with just the code as a String inside, since TruffleRuby cannot expose any bytecode, but that would probably not work for many usages of RubyVM::InstructionSequence, and so I think it doesn't make much sense either.

> So I think you can just ignore RubyVM module.

In some sense, this is what I want, make it clear to everyone that `RubyVM` functionality is specific to MRI and will not be implemented on other Ruby implementations.
As a consequence, using `RubyVM` without a fallback is equivalent to saying "this code can only run on MRI and will not run on other Ruby implementations, until such a fallback is provided or RubyVM is no longer used".
I think making it clear requires a rename.
Without a rename, it's not clear. For instance, we just discussed in this issue and I think we now agree `RubyVM` is not portable but it wasn't clear like that in the beginning.
And that's Ruby implementers discussing, how about users? How should they know `RubyVM` is MRI-specific?
I think if `RubyVM` was renamed to `CRuby`, `YARV` or `MRI`, it would be crystal clear this is all MRI-specific.

One way to make it a bit clearer for users is improving the documentation of `RubyVM` to make it clear everything under it is MRI-specific, and no other Ruby implementation defines that module.
I will make a patch for that, but I think renaming the module is still the best way to communicate this.
It also gives a chance to existing users of RubyVM to realize their code is MRI-specific.

----------------------------------------
Bug #15743: RubyVM should be renamed to CRuby
https://bugs.ruby-lang.org/issues/15743#change-77499

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: Next Major
* ruby -v: ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
My understanding is that `RubyVM` is supposed to only exist on MRI/CRuby, and not on any other Ruby implementation.
In fact, almost all features under `RubyVM` are not realistically implementable on other major Ruby implementations (JRuby, TruffleRuby, Rubinius).

Unfortunately, the name doesn't reflect that it is specific to CRuby, e.g., JRuby/TruffleRuby/Rubinius are also "Ruby VMs".
And as a result it is not clear for many Ruby users that RubyVM is CRuby-specific.

The documentation is also unclear:
```
The RubyVM module provides some access to Ruby internals. This module is
for very limited purposes, such as debugging, prototyping, and research.
 Normal users must not use it.
```

So I propose to rename RubyVM to CRuby.
That way, it is clear for everyone that this module is CRuby-specific.
It's also consistent with the JRuby module, the TruffleRuby module and the Rubinius module.

Proposed migration path:

* Introduce CRuby as an alias of RubyVM on `trunk`, and deprecate the RubyVM constant on `trunk` (for 2.7).
* Remove `RubyVM` in Ruby 3.0.

What do you think?

cc @ko1 @k0kubun @headius



-- 
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>