https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112013-01-26T00:06:15ZRuby Issue Tracking SystemRuby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=356352013-01-26T00:06:15Ztrans (Thomas Sawyer)
<ul></ul><p>Priority: High</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=364632013-02-18T08:52:31Zko1 (Koichi Sasada)
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li><li><strong>Target version</strong> changed from <i>2.6</i> to <i>2.1.0</i></li></ul> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=410012013-08-09T02:03:31Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>Could you summarize this?<br>
This is hard to read for me.</p>
<p>Or Abstract/Background/Detail/Use case/Conclusion structure may help me.</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=410092013-08-09T10:52:22Ztrans (Thomas Sawyer)
<ul></ul><p>Sure. I'll lay it out in it's more basic terms, step by step:</p>
<ul>
<li>
<p>Ruby allows us to override the Kernel #require and #load methods.</p>
</li>
<li>
<p>That may seem dangerous, but used carefully it allows us to do useful and/or interesting things with the load system.</p>
</li>
<li>
<p>The most famous example of such a use is RubyGems itself, but there are others.</p>
</li>
<li>
<p>I have developed such a system myself. I have used in house for many years, but have never been able to release it.</p>
</li>
<li>
<p>A severe limitation for such systems is that #autoload can't be hooked into because it uses an internal require method (in the C code) rather than an exposed method.</p>
</li>
<li>
<p>The inability to override autoload's require prevents any alternate load system from fully functioning as it should.</p>
</li>
<li>
<p>For RubyGems it is not a serious issue b/c the <code>gem</code> method can be called first it mitigates the problem. Nonetheless it still remains a minor issue (see <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: autoload Can't Require Gems (Closed)" href="https://bugs.ruby-lang.org/issues/4233">#4233</a>).</p>
</li>
<li>
<p>For other systems, such as my own, it is a huge issue. My system simply cannot be used generally b/c it will not be able to work with any library that uses autoload.</p>
</li>
<li>
<p>The fix is fairly simple. The require method that autoload uses simply needs to be made accessible via Ruby. Alternatively, autoload can be made to use the standard require method instead.</p>
</li>
</ul>
<p>HTH</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=410612013-08-10T14:43:51Ztrans (Thomas Sawyer)
<ul></ul><p>So it wasn't discussed. Thanks bunches.</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=410632013-08-10T18:25:23Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>I have DevelopersMeeting20130831Japan and we can discuss about this there.<br>
So could you prepare a slide? and we discuss about this and provide our view.</p>
<p>Anyway thank you for summarize but it is still confusing.<br>
I wrote your proposal in doc/contributing.rdoc's style as far as I understand.<br>
Could you edit if your thought is not reflected to this.<br>
<a href="http://www.ruby-doc.org/core-2.0/doc/contributing_rdoc.html#label-How+To+Request+Features" class="external">http://www.ruby-doc.org/core-2.0/doc/contributing_rdoc.html#label-How+To+Request+Features</a></p>
<p>[Abstract]<br>
autoload's require should be hookable</p>
<p>[Background]<br>
I'm making my own packaging system.<br>
But I'm in trouble because current autoload uses ruby's internal require and I cannnot hook it.<br>
I want to hook it and use my package system's custom require.</p>
<p>[Proposal]<br>
call Ruby's require method in autoload</p>
<p>[Details]</p>
<a name="If-it-has-complicated-feature-describe-it"></a>
<h1 >If it has complicated feature, describe it<a href="#If-it-has-complicated-feature-describe-it" class="wiki-anchor">¶</a></h1>
<p>[Usecase]<br>
Packaging system which handles auto-loading.</p>
<p>[Discussion]</p>
<a name="Discuss-about-this-proposal-A-list-of-pros-and-cons-will-help-start-discussion"></a>
<h1 >Discuss about this proposal. A list of pros and cons will help start discussion.<a href="#Discuss-about-this-proposal-A-list-of-pros-and-cons-will-help-start-discussion" class="wiki-anchor">¶</a></h1>
<p>[Limitation]</p>
<a name="Limitation-of-your-proposal"></a>
<h1 >Limitation of your proposal<a href="#Limitation-of-your-proposal" class="wiki-anchor">¶</a></h1>
<p>[Another alternative proposal]</p>
<a name="If-there-are-alternative-proposals-show-them"></a>
<h1 >If there are alternative proposals, show them.<a href="#If-there-are-alternative-proposals-show-them" class="wiki-anchor">¶</a></h1>
<p>[See also]</p>
<a name="Links-to-the-other-related-resources"></a>
<h1 >Links to the other related resources<a href="#Links-to-the-other-related-resources" class="wiki-anchor">¶</a></h1> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=410672013-08-10T23:34:46Ztrans (Thomas Sawyer)
<ul></ul><p>= Abstract<br>
Autoload's require should be hookable.</p>
<p>= Background<br>
I'm making my own load system. It is badly handicapped because current autoload<br>
uses Ruby's internal require and I cannot hook it. I want to hook it to my<br>
load system's custom require. I have other projects that are effected by this<br>
issue too.</p>
<p>= Proposal<br>
Call Ruby's require method in autoload.</p>
<p>= Details<br>
The proposal is fairly straight-forward. The only complication is whether<br>
autoload should have it's own special require method, rather then use<br>
Ruby's regular require method. I can't think of any reasons for it have it's<br>
own, but maybe there are. If so Ruby would need a new method,<br>
e.g. Kernel.autoload_require, so it can be hooked into.</p>
<p>= Usecase<br>
Developing alternate load or packaging systems which handle auto-loading.<br>
RubyGems would also benefit a little.</p>
<p>= Discussion<br>
The pros of this proposal is that it allows developers to fully explore<br>
alternatives in load/package systems for Ruby. I can't think of any cons.</p>
<p>= Limitation<br>
No limitations that I can think of.</p>
<p>= Another alternative proposal<br>
As mentioned in Detail, if for some reason there is an issue with autoload using Ruby's require method,<br>
the alternative is to create a special require method for it.</p>
<p>= See Also</p>
<ul>
<li>Issues
<ul>
<li>{Latest issue}[https://bugs.ruby-lang.org/issues/7716]</li>
<li>{Gem issue}[https://bugs.ruby-lang.org/issues/4233]</li>
</ul>
</li>
<li>Effected Projects
<ul>
<li>{Realms}[https://github.com/rubyworks/realms]</li>
<li>{Loadable}[https://github.com/rubyworks/loadable]</li>
<li>{Backload}[https://github.com/rubyworks/backload]</li>
<li>{RubyGems}[https://github.com/rubygems/rubygems]</li>
</ul>
</li>
</ul> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=414822013-08-31T16:47:43Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>I understand your motivation.</p>
<p>But autoload is invoked asynchronously so hooking it may be dangerous sometimes especially under threading environment.<br>
How do you think?</p>
<p>Matz.</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=415102013-09-01T10:55:13Ztrans (Thomas Sawyer)
<ul></ul><p>Hmmm.. require and load are never invoked asynchronously?</p>
<p>I am not sure it matters though. Its use is for very specific case. Can it be left to the programmer to ensure thread safety? I don't think the hook can be made thread safe automatically, can it?</p> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=447552014-01-30T06:16:44Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Target version</strong> changed from <i>2.1.0</i> to <i>2.2.0</i></li></ul> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=693012018-01-05T21:00:39Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.2.0</i></del>)</li></ul> Ruby master - Bug #7716: Readdressing Autoloadhttps://bugs.ruby-lang.org/issues/7716?journal_id=796442019-07-15T19:46:54Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul><p>autoload was modified to call <code>require</code> in <a class="changeset" title="* variable.c: Change autoload to call `require` through Ruby rather than directly calling `rb_r..." href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/cd465d552c3a00341f4cb7f1d7a793d0ebcb6cde">cd465d552c3a00341f4cb7f1d7a793d0ebcb6cde</a>.</p>