Feature #15752

A dedicated module for experimental features

Added by Eregon (Benoit Daloze) over 1 year ago. Updated 5 days ago.

Target version:


I believe we should introduce a module for experimental features portable across Ruby implementations.

An example of such a portable experimental feature is RubyVM.resolve_feature_path.
This feature has nothing MRI specific in it, it is a part of basic require functionality.
In the future, I would think more experimental features will be introduced, and I think RubyVM is not a good place for it.

Currently, RubyVM is sometimes used for experimental features, but I believe RubyVM should be defined only on MRI and contain only MRI-specific features.
This means it is impossible for other implementations such as JRuby and TruffleRuby to define resolve_feature_path (even though it's trivial and might be useful for some users),
and keeping RubyVM not defined for clearly marking MRI specific features are not available.

This is a problem that will only gets worse as portable experimental features are added to RubyVM.
Here is one example of adding an experimental feature but unfortunately there is no common place between Ruby implementations to add it:

If other implementations defined RubyVM, then only parts of it would be portable and other parts would be MRI specific,
which would be very confusing to both users and Ruby implementers.

Also, RubyVM doesn't really indicate by its name that it contains experimental features.

So I propose the obvious name ExperimentalFeatures.

I think such a long name is unlikely to clash with existing Object constants, is very clear,
and marks that any usage of it is by definition using not stable APIs that might be removed or changed.

In combination with #15743, this would mean we can very clearly see what kind of feature it is due to explicit naming:

  • ExperimentalFeatures.resolve_feature_path is a portable experimental feature, which can be supported on other Ruby implementations too.
  • CRuby::InstructionSequence is a CRuby/MRI-specific feature, which will only be supported on MRI.

OTOH, the RubyVM name doesn't indicate this important difference, and doesn't even indicate the features under it might experimental or not portable.

My main motivation here, is allowing other Ruby implementations to support some of these portable experimental features.
There is no reason for only MRI to be able to support code using portable experimental features.

cc mame (Yusuke Endoh) headius (Charles Nutter)

Related issues

Related to Ruby master - Feature #15743: RubyVM should be renamed to CRubyClosedActions
Related to Ruby master - Feature #15903: Move RubyVM.resolve_feature_path to Kernel.resolve_feature_pathClosedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #15966: Introducing experimental features behind a flag, disabled by defaultRejectedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #14844: Future of RubyVM::AST? Openyui-knk (Kaneko Yuichiro)Actions

Also available in: Atom PDF